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

LeetCode 132

.leetcode(513. Find Bottom Left Tree Value)

https://leetcode.com/problems/find-bottom-left-tree-value/ 1. 2022.02.06 시도 소요시간: 18분(전역변수), 10분(bfs) // 전역변수 class Solution { private int maxDepth = -1; private int max = Integer.MIN_VALUE; public int findBottomLeftValue(TreeNode root) { dfs(root, 0); return max; } private void dfs(TreeNode root, int depth) { if (root == null) { return; } dfs(root.left, depth+1); dfs(root.right, depth+1); if (r..

알고리즘 풀이 2022.02.06

.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
반응형