Greedy Algorithms8 sections · 316 units
Open in Course

Problem - Class Photos

Taller in back row

Two classes of nn students each stand in two rows for a photo. Every student in the back row must be strictly taller than the one directly in front.

Given heights of both classes, determine if a valid arrangement exists. Example: class1 = [55, 88, 11, 33, 44], class2 = [66, 99, 22, 44, 55]. Can you arrange them?

The constraint is strict inequality, so equal heights in the same column break the rule. Your strategy: sort both classes and check if every back-row student is taller than the corresponding front-row student.