FCC: "Where do I belong" without sorting

I added spoiler tags since your solution works.

I think that your solution is basically the approach used in the second solution on the hints page: freeCodeCamp Challenge Guide: Where do I Belong