본문 바로가기

13

[leetcode 347] Top K Frequent Elements Given a non-empty array of integers, return the k most frequent elements. 주어진 배열에서 가장 자주 등장하는 요소 k번째까지 리턴하기 Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Note: You may assume k is always valid, 1 ≤ k ≤ number of unique elements. Your algorithm's time complexity must be better than O(n log n), where n is the array's size. It's guarante.. 2020. 10. 18.
[leetcode 3] Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the ans.. 2020. 10. 13.
[leetcode 438] Find All Anagrams in a String Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100. The order of output does not matter. Example 1: Input: s: "cbaebabacd" p: "abc" Output: [0, 6] Explanation: The substring with start index = 0 is "cba", which is an anagram of "abc". T.. 2020. 10. 12.
[leetcode 621] Task Scheduler - 문제 이해가 어려웠다. return 값은 task를 전부 끝내기 위한 최소 소요 시간. 단 task를 수행하는데 있어서 조건이 있는데 하나의 task는 1unit시간에 끝난다. 하지만 같은 task사이엔 무조건 n유닛 이상의 쿨타임이 돌아야 한다. Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task o.. 2020. 10. 5.