Complexity, arrays, hashing, trees, graphs, sorting and the patterns behind coding rounds.
A sensor sends a list of integer readings where 0 means "no signal".
Write entryPoint(readings) that moves every 0 to the end of the list
while keeping the non-zero readings in their original relative order,
and returns the rearranged list. Work in place on the given list with
A warehouse prints serial codes such as "Ab-3 3ba". A code is
mirror-safe if, after ignoring every character that is not an ASCII
letter or digit and ignoring letter case, it reads the same forwards and
backwards.
Two servers each produce a log of event times in milliseconds, already sorted in non-decreasing order. Write that returns one combined list of all times, sorted in non-decreasing order. Duplicates are kept: a time that appears twice in total appears twice in
entryPoint(first, second)Why can an array return the element at any index in constant time, yet inserting a new element in the middle of the same array is slow? What does that tell you about when an array is the right structure?
What is the "two pointers" technique? Describe the two most common ways the pointers move, give a problem for each, and explain what the technique saves compared with a straightforward approach.
In Python, compare reversing a list with items[::-1], with
items.reverse(), and with a manual loop that swaps items[i] and
items[j] while moving i and j towards each other. What does each
do to memory and to other references to the list?