Code RoomCount panel shapes
HardPrep Room Coding #4933

Count panel shapes

CodingAlgorithms & data structuresMid–Staff~35 min

A patch panel has n ports, and its wiring sends whatever arrives at port i out through port wiring[i]. Every panel lists each port exactly once, so signals never merge and none is lost. Two panels have the same shape when renumbering the ports of one, one consistent renumbering applied everywhere, reproduces the other panel's wiring exactly. Two panels can share the same shape while agreeing on no single entry, and panels with different port counts never share a shape. Given the panels, return how many distinct shapes are present among them. Return 0 when no panels are given.

Implement
distinct_wiring_shapes(panels: list[list[int]]) → int
Examples
in[[[1,0,2],[0,2,1]]]out1
in[[[1,2,0],[1,0,2]]]out2
in[[[0,1,2],[2,0,1]]]out2
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 35 min
InputExpectedGot
[[[1,0,2],[0,2,1]]]1not run yetsample
[[[1,2,0],[1,0,2]]]2not run yetsample
[[[0,1,2],[2,0,1]]]2not run yetsample