목록코딩 테스트/leetcode (33)
미소를뿌리는감자의 코딩
https://leetcode.com/problems/sort-colors/description/ Sort Colors - LeetCode Can you solve this real interview question? Sort Colors - Given an array nums with n objects colored red, white, or blue, sort them in-place [https://en.wikipedia.org/wiki/In-place_algorithm] so that objects of the same color are adjacent, with the colors leetcode.com 1. 접근 방법 sort()로 풀면 쉽게 풀릴 문제이지만, 친히 ' You must solv..
https://leetcode.com/problems/largest-number/description/ Largest Number - LeetCode Can you solve this real interview question? Largest Number - Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. Since the result may be very large, so you need to return a string instead of an int leetcode.com 1. 접근 방법 문자열의 아래와 같은 특성을 이해하고 문제를 접근하는 것이 좋다..
https://leetcode.com/problems/balanced-binary-tree/ 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 1. 접근 방법 balanced가 되었는지 확인하기 위해서는, 해당 노드에서 abs(왼쪽 노드의 최대 깊이 - 오른쪽 노드의 최대 깊이) < 2 이어야 한다. 재귀적으로 밑에 노드들도 다 확인하기 때문에 abs(왼쪽 노드..

https://leetcode.com/problems/diameter-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 1. 접근 방법 트리의 가장 긴 지름을 구하는 문제이다. 우선 self.max_diameter를 선언을 해주어, 최대 length마다 값을 바꾸도록 하였다. 이후 노드를 기준으로, 왼쪽 노드의 ..