전체 글
-
[LeetCode]496. Next Greater Element IAlgorithm/LeetCode 2021. 9. 26. 20:56
The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. For each 0
-
[LeetCode] 1935. Maximum Number of Words You Can TypeAlgorithm/LeetCode 2021. 9. 25. 11:10
There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard. Example 1: Input: text = "hello world", broke..
-
[LeetCode] 442. Find All Duplicates in an ArrayAlgorithm/LeetCode 2021. 9. 25. 09:21
Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice, return an array of all the integers that appears twice. You must write an algorithm that runs in O(n) time and uses only constant extra space. Example 1: Input: nums = [4,3,2,7,8,2,3,1] Output: [2,3] Example 2: Input: nums = [1,1,2] Output: [1] Example 3: Input: ..
-
[LeetCode] 1460. Make Two Arrays Equal by Reversing Sub-arraysAlgorithm/LeetCode 2021. 9. 25. 09:09
Given two integer arrays of equal length target and arr. In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps. Return True if you can make arr equal to target, or False otherwise. Example 1: Input: target = [1,2,3,4], arr = [2,4,1,3] Output: true Explanation: You can follow the next steps to convert arr to target: 1- Reverse sub-a..