Problems - general notes Flashcards
Time complexity for this - https://leetcode.com/problems/longest-string-chain/
Time complexity: O(NSS)
(Substring generation)
Space: O(NS) (each word length matters in hash?)
https://leetcode.com/problems/maximum-of-absolute-value-expression
Manhattan distance
HashTable, HashMap, HashSet - what’s the difference?
Hash Table (CS) = HashMap (Java) = Dictionary (Python) Hash Set (CS) = HashSet (Java) = Set (Python)
What’s run length encoding in strings
https://www.geeksforgeeks.org/run-length-encoding/
https://leetcode.com/problems/game-of-life - followup
open ended question
Combination vs perumtation
Combination - order doesn’t matter. Perumation - order matters. HTH, HHT are two permutations, but just one H, H, T combination.
Given n elements, choose c elements without repetition. Order doesn’t matter. What’s the formula?
n! / (n-c)! c!
Amortized complexity - what is it?
https://leetcode.com/problems/binary-search-tree-iterator/discuss/52525/My-solutions-in-3-languages-with-Stack/53502
It’s averaged out complexity - especially if a datastructure retains state between multiple calls.
Time complexity for sorting a list of words (or strings).
nm.log(n) (m is the avg length of word, n is the total no. of words)