Code RoomSame shape lists
EasyPrep Room Coding #449

Same shape lists

CodingDatabases & SQLAlgorithms & data structuresEntry–Mid~12 min

Two integer lists have the same shape when equality between positions lines up exactly: for every pair of indices i and j, a[i] == a[j] holds precisely when b[i] == b[j]. Put differently, one list can be turned into the other by consistently renaming values, with distinct values staying distinct. Lists of different lengths never match. Return whether the two lists have the same shape. For example, [1, 2, 1] and [7, 9, 7] do; [1, 1] and [2, 3] do not; and [1, 2] versus [3, 3] also do not.

Implement
same_shape(a: list[int], b: list[int]) → bool
Examples
in[[1,2,1],[7,9,7]]outtrue
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 12 min
InputExpectedGot
[[1,2,1],[7,9,7]]truenot run yetsample