Algorithm/LeetCode
-
[LeetCode] 169. Majority ElementAlgorithm/LeetCode 2021. 9. 29. 09:34
Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Example 2: Input: nums = [2,2,1,1,1,2,2] Output: 2 Constraints: n == nums.length 1
-
[LeetCode]567. Permutation in StringAlgorithm/LeetCode 2021. 9. 26. 21:16
Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations is the substring of s2. Example 1: Input: s1 = "ab", s2 = "eidbaooo" Output: true Explanation: s2 contains one permutation of s1 ("ba"). Example 2: Input: s1 = "ab", s2 = "eidboaoo" Output: false Constraints: 1 bool: flag = False len_s1 = len(s1..
-
[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..