Complat software training 101
  • Introduction
  • Day 1
  • Day 2
  • TODO
  • Linear regression
  • Tmux
  • quick link
  • CLI more - 1
  • Vim more - 1
  • MQ
  • iv - 1
  • iv - 2
  • iv - 3
  • clear Arch
  • lv - array
  • INTERVIEW - JS
  • RDKit - read/write
  • RDKit - process
  • RDKit - transform
  • RDKit - rxn
  • SYSTEM DESIGN - Question
  • SYSTEM DESIGN - EX1
  • SYSTEM DESIGN - EX2
  • SYSTEM DESIGN - EX3
  • SYSTEM DESIGN - EX99
Powered by GitBook
On this page
  • Python array
  • 1. Anagram
  • 2. Array Pair Sum
  • 3. Find missing elements

Was this helpful?

lv - array

Previousclear ArchNextINTERVIEW - JS

Last updated 5 years ago

Was this helpful?

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?
  1. two sorted string are the same -> anagram.

  2. white space is not considered.

  3. 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