Time O(n). Space O(n)>
Tag Archives: Hash Table
Two Sum III – Data structure design – Python 3 (Week 14 – 17)
Longest Substring Without Repeating Characters – Python 3 (Week 12 -09)
Solution 1 HashMap Time complexity : O ( n ) . Index j will iterate n times. Space complexity O(min(m,n)). We need O(k) space for the sliding window, where k is the size of the Set. The size of the Set is upper bounded by the size of the string n and the size of …
Continue reading “Longest Substring Without Repeating Characters – Python 3 (Week 12 -09)”
Valid Sudoku – Python 3 (Week 12 – 08)
Time O(n^2). Space O(n^2).
Repeated DNA Sequences – Python 3 (Week 12 – 07)
Time O(n). Space O(n).
#Group Anagrams – Python 3 (Week 12 – 06)
Solution 1 class Solution: “”” @param strs: the given array of strings @return: The anagrams which have been divided into groups “”” def groupAnagrams(self, strs): # write your code here dic = {} for item in sorted(strs): sortedItem = ”.join(sorted(item)) dic[sortedItem] = dic.get(sortedItem, []) + [item] return dic.values() Time Complexity: O ( N K log …
Continue reading “#Group Anagrams – Python 3 (Week 12 – 06)”
Load Balancer – Python 3 (Week 12 – 05)
Time O(1). Space O(1).
Longest Consecutive Sequence – Python 3 (Week 12 – 04)
Time O(n). Space O(n). n is len(nums).
Unique Word Abbreviation – Python 3 (Week 12 – 03)
Time O(1). Space O(1).