Team Photo III
You're photographing two teams arranged in two rows. Every back-row player must be strictly taller than the front-row player directly in front of them.
The teams can have different sizes. Each row has max(len(front), len(back)) slots, so the smaller team's row has empty slots — an empty slot blocks nobody and is blocked by nobody. You may order each row however you like. Team front stands in the front row and team back in the back row.
Return the rows as [frontRow, backRow], each with max(len(front), len(back)) slots and null in an empty slot, or null when no valid arrangement exists. Any valid arrangement is accepted.
front = [170], back = [160, 180] -> [[null, 170], [160, 180]] front = [170, 160], back = [180, 165] -> [[160, 170], [165, 180]] front = [180], back = [160, 170] -> null
Hints
Hint 1
Sort both teams. The larger team fills its row in sorted order; the smaller team's players are then placed one by one in front of (or behind) partners from that row.
Hint 2
When the back row is full, give each front player, shortest first, the leftmost unused back slot whose player clears them — that is where they stand. Mirror it when the front row is full.