리트코드에 공식 큐레이팅 된 코딩 인터뷰에 자주 출제되는 문제의 목록입니다. 인터뷰 준비를 하는데 있어서, 모든 문제를 훑어 보실것을 강력 추천 합니다. 깊고 느리게, 우보만리 우직한 소처럼 천천히 걸어서 만리를 간다. 천천히 가더라도 끝까지 목표를 이룬다. Introduction This is LeetCode's official curated list of Top classic interview questions to help you land your dream job. Our top interview questions are divided into the following series: 이것은 LeetCode의 공식 큐레이팅 된 Top 클래식 인터뷰 질문 목록입니다. 우리의 주요 인터뷰 질문은 다음 ..
Others Here are some other questions that do not fit in other categories. We recommend: Number of 1 Bits Valid Parentheses. 191. Number of 1 Bits leetcode.com/problems/number-of-1-bits/ Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages such as Java, there is no unsigned integer type. In ..
Math Most of the math questions asked in interviews do not require math knowledge beyond middle school level. We recommend: Count Primes Power of Three. 412. Fizz Buzz leetcode.com/problems/fizz-buzz/ 피즈버즈 하나 가지고도 이런 다양한 토론을 할수 있군.. Solution You must have played FizzBuzz as kids. FizzBuzz charm never gets old. And so here we are looking at how you can take on one step at a time and impress your ..
Design These problems may require you to implement a given interface of a class, and may involve using one or more data structures. These are great exercises to improve your data structure skills. We recommend: Shuffle an Array Min Stack. 384. Shuffle an Array leetcode.com/problems/shuffle-an-array/ hint The solution expects that we always use the original array to shuffle() else some of the tes..
leetcode.com/problems/climbing-stairs/ 다른풀이도 많이 있지만, dp만 찍고 넘어감 dp배열의 인덱스에 주의하자. - 배열크기 n+1 - 시작부분 셋팅 - 루프 인덱스 class Solution: def climbStairs(self, n: int) -> int: if n == 1: return 1 dp = [0 for i in range(n+1)] dp[1] = 1 dp[2] = 2 for i in range(3, n+1): dp[i] = dp[i-1] + dp[i-2] return dp[n] leetcode.com/problems/best-time-to-buy-and-sell-stock/ 문제가 쉬운것 같지만, 아직도 설계를 버벅인다. class Solution: def..
88. Merge Sorted Array Easy 32104857Add to ListShare Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2. Example 1: Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,..
leetcode.com/problems/maximum-depth-of-binary-tree/ class Solution: def maxDepth(self, root: TreeNode) -> int: if root is None: return 0 return max(self.maxDepth(root.left), self.maxDepth(root.right)) + 1 class Solution: def maxDepth(self, root: TreeNode) -> int: stack = [] if root is not None: stack.append((1, root)) depth = 0 while stack != []: current_depth, root = stack.pop() if root is not ..
Linked List Linked List problems are relatively easy to master. Do not forget the Two-pointer technique, which not only applicable to Array problems but also Linked List problems as well. Another technique to greatly simplify coding in linked list problems is the dummy node trick. We recommend: Reverse Linked List, Merge Two Sorted Lists Linked List Cycle. For additional challenge, solve these p..
내용 및 해설 정리: inner-game.tistory.com/46 leetcode.com/problems/reverse-string/ class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ left, right = 0, len(s) - 1 while left < right: s[left], s[right] = s[right], s[left] left, right = left + 1, right - 1 leetcode.com/problems/reverse-integer/ class Solution: def reverse(self, x: int)..
Array - Top Interview Questions[EASY] (1/9) : Java 전반적인 해설은 여기에 있음(Java) : inner-game.tistory.com/38 leetcode.com/problems/remove-duplicates-from-sorted-array/ class Solution: def removeDuplicates(self, nums: List[int]) -> int: len_ = 1 if len(nums) == 0: return 0 for i in range(1, len(nums)): if nums[i] != nums[i-1]: nums[len_] = nums[i] len_ += 1 return len_ leetcode.com/problems/best-time-to-..
Others Here are some other questions that do not fit in other categories. We recommend: Number of 1 Bits Valid Parentheses. 191. Number of 1 Bits leetcode.com/problems/number-of-1-bits/ Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages such as Java, there is no unsigned integer type. In ..
Math Most of the math questions asked in interviews do not require math knowledge beyond middle school level. We recommend: Count Primes Power of Three. 412. Fizz Buzz leetcode.com/problems/fizz-buzz/ 피즈버즈 하나 가지고도 이런 다양한 토론을 할수 있군.. Solution You must have played FizzBuzz as kids. FizzBuzz charm never gets old. And so here we are looking at how you can take on one step at a time and impress your ..
Design These problems may require you to implement a given interface of a class, and may involve using one or more data structures. These are great exercises to improve your data structure skills. We recommend: Shuffle an Array Min Stack. 384. Shuffle an Array leetcode.com/problems/shuffle-an-array/ Initial Thoughts Normally I would display more than two approaches, but shuffling is deceptively ..
Dynamic Programming Here are some classic Dynamic Programming interview questions. We recommend: Climbing Stairs, Best Time to Buy and Sell Stock and Maximum Subarray. 70. Climbing Stairs leetcode.com/problems/climbing-stairs/solution/ 3번으로 풀었다. 4번부터 쬐끔 당황쓰. Summary You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many disti..
Sorting and Searching These problems deal with sorting or searching in a sorted structure. We recommend First Bad Version as a great introduction to a very important algorithm. 88. Merge Sorted Array leetcode.com/problems/merge-sorted-array/ Solution Approach 1 : Merge and sort Intuition The naive approach would be to merge both lists into one and then to sort. It's a one line solution (2 lines ..
Trees Tree is slightly more complex than linked list, because the latter(후자) is a linear data structure while the former is not. Tree problems can be solved either breadth-first or depth-first. We have one problem here which is great for practicing breadth-first traversal. We recommend: Maximum Depth of Binary Tree, Validate Binary Search Tree, Binary Tree Level Order Traversal and Convert Sorte..
Strings String type of questions were asked in interviews frequently. You will most likely encounter one during your interviews. We recommend: Reverse String, First Unique Character in a String, String to Integer (atoi) Implement strStr(). 총 8문제. 344. Reverse String 투포인터는 이렇게 쓰는 것이다. 이런 느낌의 문제. leetcode.com/problems/reverse-string/solution/ Easy Write a function that reverses a string. The input..
Array Array type of questions were asked in interviews frequently. You will most likely encounter one during your interviews. We recommend: Single Number, Rotate Array, Intersection of Two Arrays II and Two Sum 26. Remove Duplicates from Sorted Array leetcode.com/problems/remove-duplicates-from-sorted-array/ Given a sorted array nums, remove the duplicates in-place such that each element appear ..