Meta Data#
Difficulty: easy First Attempt: 2021-10-10
- Submissions: Accepted ×3
Approach#
A country is big if either condition holds, so join them with OR (SQL Template 1). The problem says at least, so use >=.
My Attempts#
All three passed: OR, OR in the other order, and a UNION of two queries. They used > although the problem says “at least”; the boundary should be >=, which the tests happened not to probe.
Solution#
SELECT name, population, area
FROM World
WHERE area >= 3000000 OR population >= 25000000;
Complexity#
One table scan, O(n).
Mistakes to Avoid#
- “At least” means
>=. - Two queries with
UNIONcan be faster with indexes, butORis usually fine.
Interview Explanation#
I filter with WHERE for an area of at least three million or a population of at least twenty-five million and return the name, population and area.
