Amazon interview question

Backtracking and hashmaps were asked