Search
⌘K

Leetcode 1029. Two City Scheduling

Assign 2n people to two cities so exactly n go to each city and the total travel cost is minimized. The core challenge is selecting which n people go to city A vs B based on their per-person cost differences (aCost - bCost), which yields a greedy sorting-based solution.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.