search(target)
, start from the top level and move right until the next node's value is greater than target
, then go down one level and continue until the bottom level is reached. Return true
if target
is found, false
otherwise.add(num)
, perform a similar traversal as search
but keep track of the predecessors at each level. Insert num
after the predecessors, randomly deciding whether to insert it at higher levels.erase(num)
, again traverse the list to find num
, and remove it by adjusting pointers at each level where it appears.