Idea is simple (inspired by tutorial) - sort kids by height (secondary by weight, both decreasing), get the first one not afraid of anyone (in code referred as captain). All other kids have less height, so they are potentially afraid of the one. But the kids with greater weight are not afraid, so we can add them to the team.
I believe that my code runs in O(N*log(N)), but I’m getting TLE. Did I missed something?