Hard2 [Algorithm][Tree][Java] 문제 풀이 #25 - 124. Binary Tree Maximum Path Sum 문제 링크 https://leetcode.com/problems/binary-tree-maximum-path-sum/ 내 풀이 int max = Integer.MIN_VALUE; public int maxPathSum(TreeNode root) { if(root.left == null && root.right == null) return root.val; recursion(root); return max; } private void recursion(TreeNode node) { if(node == null) return; if(node.left == null && node.right == null) return; int leftVal = node.left != null ? node.left.val : .. 2022. 8. 21. [Algorithm][Array] 문제 풀이 #9 - Sliding Window Maximum 문제 링크 https://leetcode.com/problems/sliding-window-maximum/ 내 코드 public int[] maxSlidingWindow(int[] nums, int k) { if(k == 1) return nums; int[] result = new int[nums.length - k + 1]; int max = Integer.MIN_VALUE; int count = 1; int maxIndex = 0; int resultIndex = 0; boolean start = false; for(int i = 0; i k - 1) max = Integer.MIN_VALUE; if(max 0) { if(re.. 2022. 7. 19. 이전 1 다음