Google 태그 관리자 아이콘
반응형

algorithm 143

.leetcode(515. Find Largest Value in Each Tree Row)

https://leetcode.com/problems/find-largest-value-in-each-tree-row/ 1. 2022.01.30 시도 소요시간: 30분 이상(다른 일때문에 측정x) class Solution { public List largestValues(TreeNode root) { LinkedList output = new LinkedList(); if (root == null) { return output; } LinkedList queue = new LinkedList(); LinkedList depthQueue = new LinkedList(); queue.offer(root); depthQueue.offer(0); while(!queue.isEmpty()) { TreeNode..

알고리즘 풀이 2022.01.30

.leetcode(876. Middle of the Linked List)

https://leetcode.com/problems/middle-of-the-linked-list/ 1. 2022.01.24 시도 소요시간: 4분 class Solution { public ListNode middleNode(ListNode head) { if (head == null) { return null; } ListNode slow = head; ListNode fast = head.next; while(fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; } if (fast == null) { return slow; } return slow.next; } } 풀이 접근 과정 slow, fast로 하면 쉽게 ..

알고리즘 풀이 2022.01.24
반응형