
Coding test
![[LeetCode] Find All Numbers Disappeared in an Array](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FvXpCX%2FbtrCXzwLFQo%2FAAAAAAAAAAAAAAAAAAAAAF-k-7UmEqJ2QDATR4hiYbWHA047t2lpEJ_Yq7nCenkI%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3D9DGYzY41mztnayE7Ht9QFeCcH5w%253D)
[LeetCode] Find All Numbers Disappeared in an Array
🔍 문제 Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. Input: nums = [4,3,2,7,8,2,3,1] Output: [5,6] Input: nums = [1,1] Output: [2] Tip) The intuition behind using a hash map is pretty clear in this case 🖥 실행 1) Answer(Hash Table) class Solution(object): def findDisappearedNumbers(self, num..
![[LeetCode] Third Maximum Number](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2Fez9s8P%2FbtrCHNW1321%2FAAAAAAAAAAAAAAAAAAAAAOFTQyqOXPyye8mGlrVWzxfr94hg2dpvTLDUD6dgeY0W%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DJSYV3sLOUaSjDX2MwtF%252BJB9rE5s%253D)
[LeetCode] Third Maximum Number
🔍 문제 Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number. Input: nums = [3,2,1] Output: 1 Explanation: The first distinct maximum is 3. The second distinct maximum is 2. The third distinct maximum is 1. 🖥 실행 1) Answer class Solution: def thirdMax(self, nums: List[int]) -> int: for i in nums: while num..
![[LeetCode] Max Consecutive Ones II](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FcDnIwS%2FbtrCHO9kdDM%2FAAAAAAAAAAAAAAAAAAAAAJhirpcMnIamzu237Pr_ZkJbYXGxrQFkTGLjJF83gyrc%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DJY7TtLYuJG48Ye%252BhKmNGh1Gq7Tw%253D)
[LeetCode] Max Consecutive Ones II
🔍 문제 Given a binary array nums, return the maximum number of consecutive 1's in the array if you can flip at most one 0. nput: nums = [1,0,1,1,0] Output: 4 Explanation: Flip the first zero will get the maximum number of consecutive 1s. After flipping, the maximum number of consecutive 1s is 4. 🖥 실행 1) Answer class Solution(object): def findMaxConsecutiveOnes(self, nums): # previous and current l..
![[LeetCode] Height Checker](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FdFF6W0%2FbtrCGbkhbHk%2FAAAAAAAAAAAAAAAAAAAAAJ22-Eerb64VavM98X5_CFyNisc6CBuyzK3ssEHP_7Wz%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3D%252BAJNFgIQWUoSJc%252B5WAbk6bQihl8%253D)
[LeetCode] Height Checker
🔍 문제 A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected[i] is the expected height of the ith student in line. You are given an integer array heights representing the current order that the students are standing in. Eac..
![[LeetCode] Move Zeroes](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbkuKZL%2FbtrCHDmkLD3%2FAAAAAAAAAAAAAAAAAAAAAP8yudXQyKU0f1UDRxziHD7aRQ7Y9jwDtuJU6Bh-MKKL%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3D8kZbI80wrlzTV4FJc44mBPtOvHw%253D)
[LeetCode] Move Zeroes
🔍 문제 Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0] Input: nums = [0] Output: [0] 🖥 실행 1) Answer class Solution: def moveZeroes(self, nums: List[int]) -> None: n = 0 while nums.count(0) > n: nums.remove(..
![[LeetCode] Replace Elements with Greatest Element on Right Side](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FcPeG2o%2FbtrCFKtpsNn%2FAAAAAAAAAAAAAAAAAAAAAITdqSLp8mZZ8v9xq3J1hjZEcTaqAvJ7uYPdfmlprCKH%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DHgzKWkf5PNym9V6Ip1qFO7jhb%252BQ%253D)
[LeetCode] Replace Elements with Greatest Element on Right Side
🔍 문제 Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Explanation: - index 0 --> the greatest element to the right of index 0 is index 1 (18). - index 1 --> the greatest element to the right of index 1 is in..
![[LeetCode] Valid Mountain Array](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FlxqS0%2FbtrCEdvXVn6%2FAAAAAAAAAAAAAAAAAAAAAIgi7Ku8ciuGpOqzKVpxk8-x92Ft-aY378VzOk7InrMx%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DaH04dsk42nHWnsF0S3r6TY747UA%253D)
[LeetCode] Valid Mountain Array
🔍 문제 Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 ... > arr[arr.length - 1] Input: arr = [2,1] Output: false Input: arr = [3,5,5] Output: false Input: arr = [0,3,2,1] Output: true 🖥 실행 ..
![[LeetCode] Merge Sorted Array](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FcRBhhr%2FbtrCEopEAtU%2FAAAAAAAAAAAAAAAAAAAAAO6UPJi1rU7OVnw3CPfBCWtb8F_TCNSuT6PqvA8fBTal%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DQobiGzXqDuTvxCpTWHr10jWU35c%253D)
[LeetCode] Merge Sorted Array
🔍 문제 You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a ..