algorithm/리트코드

문제 https://leetcode.com/problems/evaluate-reverse-polish-notation/?envType=study-plan-v2&envId=top-interview-150 더보기 Example 1: Input: tokens = ["2","1","+","3","*"] Output: 9 Explanation: ((2 + 1) * 3) = 9 Example 2: Input: tokens = ["4","13","5","/","+"] Output: 6 Explanation: (4 + (13 / 5)) = 6 Example 3: Input: tokens = ["10","6","9","3","+","-11","*","/","*","17","+","5","+"] Output: 22 Exp..
문제 https://leetcode.com/problems/min-stack/?envType=study-plan-v2&envId=top-interview-150 더보기 Example 1: Input ["MinStack","push","push","push","getMin","pop","top","getMin"] [[],[-2],[0],[-3],[],[],[],[]] Output [null,null,null,null,-3,null,0,-2] Explanation MinStack minStack = new MinStack(); minStack.push(-2); minStack.push(0); minStack.push(-3); minStack.getMin(); // return -3 minStack.pop()..
문제 https://leetcode.com/problems/majority-element/?envType=study-plan-v2&envId=top-interview-150 더보기 Example 1: Input: nums = [3,2,3] Output: 3 Example 2: Input: nums = [2,2,1,1,1,2,2] Output: 2 ✔ 문제접근 #1 해시테이블[통과] ⭕ Intuition 각 요소값이 등장하는 횟수를 해시테이블을 통하여 관리해준다. Algorithm 배열을 순회하며 각 요소가 등장하는 횟수를 count라는 dict 자료구조에 기록해준다.초기값은 배열의 첫번째 값의 등장횟수 1을 최대라고 생각하고 시작한다. 등장 횟수를 기록해주면서 동시에 현재까지 가장 많이 등장한 횟수의 최..
문제 https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/?envType=study-plan-v2&envId=top-interview-150 더보기 Example 1: Input: nums = [1,1,1,2,2,3] Output: 5, nums = [1,1,2,2,3,_] Explanation: Your function should return k = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively. It does not matter what you leave beyond the returned k (hence they are underscore..
문제 https://leetcode.com/problems/remove-duplicates-from-sorted-array/?envType=study-plan-v2&envId=top-interview-150 더보기 Example 1: Input: nums = [1,1,2] Output: 2, nums = [1,2,_] Explanation: Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively. It does not matter what you leave beyond the returned k (hence they are underscores). Example 2: Input: num..
문제 https://leetcode.com/problems/remove-element/?envType=study-plan-v2&envId=top-interview-150 더보기 Contraints: 0
문제 https://leetcode.com/problems/merge-sorted-array/?envType=study-plan-v2&envId=top-interview-150 더보기 Example 1: Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3 Output: [1,2,2,3,5,6] Explanation: The arrays we are merging are [1,2,3] and [2,5,6]. The result of the merge is [1,2,2,3,5,6] with the underlined elements coming from nums1. Example 2: Input: nums1 = [1], m = 1, nums2 = [],..
Don't stop 훈
'algorithm/리트코드' 카테고리의 글 목록 (3 Page)