The question clearly states:
“In this case, we consider population of more than 1,000,000 to be over- populated and less than 5,000 to be under-populated.”
Yet the given answer uses “less than or equal to” ("$lte") and also “greater than or equal to” ($“gte”). These are incorrect. The question does not specify equality. The answer should use ("$gt") and ("$lt") respectively.
Also reading the other questions on similar threads. The reason people are having issues is because they have mutated the integer type of a number of documents to strings, so they are not being included in their returned queries.