Greedy approach:
Sort both classes by height.
Determine which class goes in front (the one with the shorter tallest student).
Compare position by position: each back-row student must be strictly taller than the corresponding front-row student. If all comparisons pass, return true. Otherwise, false. It works because if tallest of class A < tallest of class B, then class A must be in front. And sorted order maximizes the chance of success at each position. Time: . Space: .