Code RoomMap indices between lists
EasyPrep Room Coding #445

Map indices between lists

CodingDatabases & SQLAlgorithms & data structuresEntry–Mid~10 min

A quiz app shuffled its question ids. You have the original order in list a and the shuffled order in list b; both lists contain exactly the same distinct integers, just arranged differently. For each position i of a, find where that id landed in b, and return the list r with r[i] equal to the index of a[i] within b. For example, a = [12, 28, 46] and b = [46, 12, 28] give [1, 2, 0]. Avoid searching b repeatedly — one preprocessing pass should make every lookup O(1).

Implement
position_map(a: list[int], b: list[int]) → list[int]
Examples
in[[12,28,46],[46,12,28]]out[1,2,0]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 10 min
InputExpectedGot
[[12,28,46],[46,12,28]][1,2,0]not run yetsample