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

  1. two sorted string are the same -> anagram.

  2. white space is not considered.

  3. solution = hash table

2. Array Pair Sum

solution: sets for checking

3. Find missing elements

Last updated

Was this helpful?