전체 글 39

[1주차] 141. Linked List Cycle

https://leetcode.com/problems/linked-list-cycle/?envType=study-plan-v2&envId=top-interview-150 Linked List Cycle - LeetCode Can you solve this real interview question? Linked List Cycle - Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuo leetcode.com 📝 문제..

[1주차] 209. Minimum Size Subarray Sum

https://leetcode.com/problems/minimum-size-subarray-sum/description/?envType=study-plan-v2&envId=top-interview-150 Minimum Size Subarray Sum - LeetCode Can you solve this real interview question? Minimum Size Subarray Sum - Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no s..

[1주차] 125. Valid Palindrome

https://leetcode.com/problems/valid-palindrome/?envType=study-plan-v2&envId=top-interview-150 Valid Palindrome - LeetCode Can you solve this real interview question? Valid Palindrome - A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric cha leetcode.com 이 문제부터..

[1주차] 55. Jump Game

https://leetcode.com/problems/jump-game/?envType=study-plan-v2&envId=top-interview-150 Jump Game - LeetCode Can you solve this real interview question? Jump Game - You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can leetcode.com 📄 문제 1차원 정수 배열 nums가..

[1주차] 122. Best Time to Buy and Sell Stock II

https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ Best Time to Buy and Sell Stock II - LeetCode Can you solve this real interview question? Best Time to Buy and Sell Stock II - You are given an integer array prices where prices[i] is the price of a given stock on the ith day. On each day, you may decide to buy and/or sell the stock. You can only hold leetcode.com 📝 문제 정수 1차원 배열이 ..

[1주차] 121. Best Time to Buy and Sell Stock

https://leetcode.com/problems/jump-game/?envType=study-plan-v2&envId=top-interview-150 Jump Game - LeetCode Can you solve this real interview question? Jump Game - You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can leetcode.com 📝 문제 정수 1차원 배열이 주어진다..

[1주차] 189. Rotate Array

https://leetcode.com/problems/rotate-array/description/?envType=study-plan-v2&envId=top-interview-150 문제 주어진 nums 배열을 오른쪽으로 k 만큼 회전시켜라. 단 k >= 0 이다. 풀이 보자마자 LinkedList를 이용한 Queue 자료구조가 생각났고 해결했다. 좀더 직관적으로 알아볼 수 있게 Deque를 사용했다. fun rotate(nums: IntArray, k: Int): Unit { val queue: Deque = LinkedList() nums.forEach { queue.addLast(it) } repeat(k % nums.size) { queue.addFirst(queue.removeLast()) } ..

[1주차] 169. Majority Element

https://leetcode.com/problems/majority-element/?envType=study-plan-v2&envId=top-interview-150 문제 주어진 정수배열 nums 에서 nums.size / 2 보다 많이 나오는 원소를 리턴한다. 단, 조건에 맞는 원소는 반드시 존재한다. 해결 문제를 보자마자 생각난 방식 fun majorityElement(nums: IntArray): Int { val map = mutableMapOf() nums.forEach { val prev = map.getOrDefault(it, 0) map[it] = prev + 1 } map.forEach { if (it.value > nums.size / 2) { return it.key } } retu..

[1주차] 80. Remove Duplicates from Sorted Array II

https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/?envType=study-plan-v2&envId=top-interview-150 Remove Duplicates from Sorted Array II - LeetCode Can you solve this real interview question? Remove Duplicates from Sorted Array II - Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place [https://en.wikipedia.org/wiki/In-place_algorithm] such..

[1주차] 27. Remove Element

https://leetcode.com/problems/remove-element/?envType=study-plan-v2&envId=top-interview-150 Remove Element - LeetCode Can you solve this real interview question? Remove Element - Given an integer array nums and an integer val, remove all occurrences of val in nums in-place [https://en.wikipedia.org/wiki/In-place_algorithm]. The order of the elements may be changed. Then r leetcode.com 📝 문제 오름차순으..