Problems - general notes Flashcards

1
Q

Time complexity for this - https://leetcode.com/problems/longest-string-chain/

A

Time complexity: O(NSS)
(Substring generation)
Space: O(NS) (each word length matters in hash?)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

https://leetcode.com/problems/maximum-of-absolute-value-expression

A

Manhattan distance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

HashTable, HashMap, HashSet - what’s the difference?

A
Hash Table (CS) = HashMap (Java) = Dictionary (Python)
Hash Set (CS) = HashSet (Java) = Set (Python)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s run length encoding in strings

A

https://www.geeksforgeeks.org/run-length-encoding/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

https://leetcode.com/problems/game-of-life - followup

A

open ended question

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Combination vs perumtation

A

Combination - order doesn’t matter. Perumation - order matters. HTH, HHT are two permutations, but just one H, H, T combination.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Given n elements, choose c elements without repetition. Order doesn’t matter. What’s the formula?

A

n! / (n-c)! c!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Amortized complexity - what is it?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Time complexity for sorting a list of words (or strings).

A

nm.log(n) (m is the avg length of word, n is the total no. of words)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly