
문제 https://leetcode.com/problems/keys-and-rooms/description/ Keys and Rooms - LeetCode Can you solve this real interview question? Keys and Rooms - There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. Whe leetcode.com 풀이 코드 class Solution { /** * 0번째 room을 방문하..

문제 https://leetcode.com/problems/create-binary-tree-from-descriptions/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 코드 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNo..

문제 https://leetcode.com/problems/symmetric-tree/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 코드 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode ri..

문제 https://leetcode.com/problems/two-sum-iv-input-is-a-bst/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 코드 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * ..

문제 https://leetcode.com/problems/count-good-nodes-in-binary-tree/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 코드 DFS로 Tree를 순회한다. 각 Node의 값이 순회 경로 상에 있는 Node들의 최댓값보다 크면 최댓값을 변경하고 answer를 1 증가한다. Tree를 모두 ..

문제 https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 코드 /** * Definition for a binary tree node. * public class TreeNode { * int val; *..

문제 https://leetcode.com/problems/reverse-odd-levels-of-binary-tree/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 코드 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode ..

문제 https://leetcode.com/problems/all-paths-from-source-to-target/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이 코드 class Solution { static List answer; //allPathsSourceTarget 메소드의 return 값을 담을 전역변수 선언. public List allP..
풀이 시간초과로 고생한 문제 LinkedList 클래스, ListIterator 인터페이스를 이용하여 해결하였다. import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.LinkedList; import java.util.ListIterator; public class BOJ_1406 { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(S..