We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For the Meeting Point challenge: With N≤1000, brute-force O(N²) works—pick each house as meeting point, sum Manhattan distances (|dx|+|dy|) to all houses, output the minimum sum.
Meeting Point
You are viewing a single comment's thread. Return to all comments →
For the Meeting Point challenge: With N≤1000, brute-force O(N²) works—pick each house as meeting point, sum Manhattan distances (|dx|+|dy|) to all houses, output the minimum sum.
Python solution:
Sample input (4 houses: (0,1) (2,5) (3,1) (4,0)) outputs 10. Handles large coords with int. TLE? Optimize sorting for medians but eval at points only.