Team Photo II
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 whether a valid arrangement exists.
front = [170], back = [160, 180] -> true (170 faces 180; 160 has nobody in front) front = [180], back = [160, 170] -> false (nobody is taller than 180) front = [150, 160, 170], back = [165] -> true (165 stands behind 150 or 160)
Hints
Hint 1
Only aligned pairs constrain anything, so the smaller team must be matched one-to-one into the larger one.
Hint 2
Greedy on sorted arrays: give each front player the smallest back player who still clears them — or, when the front row is the full one, give each back player the tallest front player they still clear.