This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/partition-labels/ | |
| // | |
| // Time: O(n) | |
| // Space: O(1) | |
| // | |
| // n = number of letters in string | |
| // .................... // | |
| func partitionLabels(s string) []int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/container-with-most-water/ | |
| // | |
| // Time: O(n) | |
| // Space: O(1) | |
| // | |
| // n = number of elements in array | |
| // .................... // | |
| func maxArea(height []int) int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/merge-intervals/ | |
| // | |
| // Time: O(n log n) | |
| // Space: O(n) | |
| // | |
| // n = number of intervals | |
| // .................... // | |
| func merge(intervals [][]int) [][]int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/top-k-frequent-elements/ | |
| // | |
| // Time: O(n log k) | |
| // Space: O(n) | |
| // | |
| // n - number of unique elements in array | |
| // .................... // | |
| type item struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/top-k-frequent-words/ | |
| // | |
| // Time: O(n log k) | |
| // Space: O(n) | |
| // | |
| // n = number of unique words in array | |
| // .................... // | |
| type item struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/number-of-islands/ | |
| // | |
| // Time: O(n*m) | |
| // Space: O(n*m) | |
| // | |
| // n = number of rows, m = number of columns | |
| // .................... // | |
| func numIslands(grid [][]byte) int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/find-all-anagrams-in-a-string/ | |
| // | |
| // Time: O(n) | |
| // Space: O(1) | |
| // | |
| // n - number of elements in array | |
| // .................... // | |
| func findAnagrams(s string, p string) []int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/4sum/ | |
| // | |
| // Time: O(n^3) | |
| // Space: O(1) | |
| // | |
| // n = number of elements in array | |
| // .................... // | |
| func fourSum(nums []int, target int) [][]int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/single-number/ | |
| // | |
| // Time: O(n) | |
| // Space: O(1) | |
| // | |
| // n - number of elements in array | |
| // .................... // | |
| func singleNumber(nums []int) int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/search-in-rotated-sorted-array-ii/ | |
| // | |
| // Time: O(log n) average | |
| // Space: O(1) | |
| // | |
| // n = number of elements in the array | |
| // .................... // | |
| func search(nums []int, target int) bool { |
NewerOlder