Which earlier position can pair with this one?

Target 9, input [2,5,7]. Just before reading 7, draw the map if it stores a position for each earlier value.

1 / 6

When can a 4 pair with a 4?

Trace [4,1] and [4,4] with target 8. Decide whether to look up the complement before or after recording the current position.

2 / 6

Do equal sets and equal lengths settle it?

Compare "abb" and "aab". Count the first word, then spend its letters to construct the second. Where does payment first fail?

3 / 6

Can a negative balance recover?

Read one character from each word at a time, adding for "bc" and subtracting for "cb". Predict both balances after each step.

4 / 6

Who was first?

In "teeter", the final counts are t → 2, e → 3, r → 1. What does the function return? Change the input to "teerk" and choose between the singletons.

5 / 6

Change the output

For three 6s and target 12, one caller needs a pair of positions. Another needs the number of pairs. What must a map entry tell each caller?

6 / 6
←/→ or click edges to navigate · ? help · N notes · F fullscreen