본문 바로가기

LeetCode41

LeetCode 74 Search a 2D Matrix 문제 URL : https://leetcode.com/problems/search-a-2d-matrix/ Search a 2D Matrix - LeetCode 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 문제 접근법 : 매우 쉬운 문제입니다. O^2탐색을 했다면 안보셔도 됩니다. 하지만 문제 형식이 binary search를 사용해서 풀라고 하듯이 배열값에 조건을 줬으니 binary search를 써서 풀어보자구여 배열의 사이즈를 n,m이라할때 모든행의 가장 왼쪽과 오른쪽에 .. 2021. 11. 17.
LeetCode 112 Path Sum 문제 URL : https://leetcode.com/problems/path-sum/submissions/ Path Sum - LeetCode 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 문제 접근법 : 루트에서 리프노드까지 경로의 합을 다구하여 targetSum을 구하는 문제입니다. 루트에서 리프노드까지의 합을 구하여 tarsum이 하나라도 있으면 됩니다. 소스코드 : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2.. 2021. 11. 14.
LeetCode 257 Binary Tree Paths 문제 URL : https://leetcode.com/problems/binary-tree-paths/ Binary Tree Paths - LeetCode 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를 이용하면 되겠고 리프노드라는건 양쪽 왼쪽자식과 오른쪽자식이 없는것을 뜻하니 없을때는 ->를 안붙여주면되는거니 어렵지 않은문제입니다. 소스코드 : 1 2 3 4 5 6 7 8 9 10 11 .. 2021. 11. 14.
LeetCode 103. Binary Tree Zigzag Level Order Traversal 문제 URL : https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Binary Tree Zigzag Level Order Traversal - LeetCode 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 문제 접근법 : 지그재그 탐색한순서를 리턴하는건데 기본적인 핵심은 bfs를 이용해야합니다. bfs로 탐색한후 각 높이마다 각 노드들을 순서대로 저장할수있고 bfs로 탐색한것을 한번은 0~사이즈-1만.. 2021. 8. 3.