[99클럽] 99클럽 코테 스터디 15일차 TIL - DFS/BFS
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Maximum Depth of Binary Tree (출처 하단 표기) 문제Given the root of a binary tree, return its maximum depth.A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 제한사항The number of nodes in the tree is in the range [0, 10⁴].-100 입출력 예rootreturn[3,9,20,null,null,15,7]3[1,null,2]2 풀이/** * Definition for a binary tree ..
[99클럽] 99클럽 코테 스터디 14일차 TIL - DFS/BFS
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Invert Binary Tree (출처 하단 기재) 문제Given the root of a binary tree, invert the tree, and return its root. 제한사항The number of nodes in the tree is in the range [0, 100].-100 입출력 예rootreturn[4,2,7,1,3,6,9][4,7,2,9,6,3,1][2,1,3][2,3,1][ ][ ] 풀이/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {}..
[99클럽] 99클럽 코테 스터디 13일차 TIL - DFS/BFS
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Evaluate Boolean Binary Tree (출처 하단 표기) 문제You are given the root of a full binary tree with the following properties:Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.Non-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 represents the boolean AND.The evaluation of a node is as follows:If the node is a leaf nod..
[99클럽] 99클럽 코테 스터디 12일차 TIL - DFS/BFS
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Find a Corresponding Node of a Binary Tree in a Clone of That Tree (출처 하단 표기) 문제Given two binary trees original and cloned and given a reference to a node target in the original tree.The cloned tree is a copy of the original tree.Return a reference to the same node in the cloned tree.Note that you are not allowed to change any of the two trees or the target node and the answer m..
[99클럽] 99클럽 코테 스터디 11일차 TIL - DFS/BFS
·
코딩테스트 연습/99클럽
오늘의 문제LeetCode - Range Sum of BST (출처 하단 기재) 문제Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. 제한사항The number of nodes in the tree is in the range [1, 2 * 10 ⁴ ].1 1 All Node.val are unique.입출력 예rootlowhighreturn[10,5,15,3,7,null,18]71532[10,5,15,3,7,13,18,1,null,6]61023 풀이/** * Defi..
[99클럽] 99클럽 코테 스터디 8일차 TIL - 정렬 (Sort)
·
코딩테스트 연습/99클럽
오늘의 문제Leetcode - Count Pairs Whose Sum is Less than Target (출처 하단 표기) 문제Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0  and nums[i] + nums[j] . 제한사항1 -50 입출력 예numstarget[-1,1,2,3,1]2[-6,2,5,-2,-7,-1,3]-2 풀이import java.util.*;class Solution { public int countPairs(List nums, int target) { // target보다 작은 짝의 개수 int ..
[99클럽] 99클럽 코테 스터디 6일차 TIL - 힙(Heap)
·
코딩테스트 연습/99클럽
오늘의 문제Leetcode - Maximum Product of Two Elements in an Array (출처 하단 표기) 문제Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). 제한사항2 1 입출력 예inputoutput[3, 4, 5, 2]12[1, 5, 4, 5]16[3, 7]12 풀이import java.util.*;class Solution { public int maxProduct(int[] nums) { Arrays.sort(nums); int m..
[99클럽] 99클럽 코테 스터디 4일차 TIL - 스택(Stack)
·
코딩테스트 연습/99클럽
오늘의 문제Leetcode - Valid Parentheses (출처 하단 표기) 문제Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brackets.Open brackets must be closed in the correct order.Every close bracket has a corresponding open bracket of the same type.제한사항1 s consists of pare..