lv - array
static array = a fixed capacity that needs to be specified at allocation.
dynamic array = allows elements to be added or removed, without specify length in the beginning.

python list
python dict
indexing
O(1)
get item
O(1)
index assignment
O(n)
iteration
O(n)
pop(i)
O(n)
copy
O(n)
Python array
array sequence: [1]List, [2]tuple, [3]string; (support indexing)
Lists = dynamic arrays of pointers. (indexing = O(1))
RAM (random access memory) = indexing with O(1)
Python Unicode = 2 Bytes
indexing = start + cell_size * index
slice = new array instance pointing to same locations.

shallow copy = copy reference
deep copy = copy elements
dynamic array with amortized to append elements: average expanding op is O(1), actually ~O(3)

1. Anagram
Given: s1 = 'god', s2 = 'd og'
Question: is s1 == s2?
two sorted string are the same -> anagram.
white space is not considered.
solution = hash table
2. Array Pair Sum
Given: integer array = [1, 3, 2, 2], target = 4
Question: return [1]pairs sum = target [2]uniq pairs
solution: sets for checking
3. Find missing elements
Given: arr_one = [1, 2, 3, 4, 5, 6, 7] non-negative array, arr_two = [3, 7, 2, 1, 4, 6] shuffuled & deleted random
Question: find missing
Last updated
Was this helpful?