Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7883785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:37:38+00:00 2026-06-03T04:37:38+00:00

The problem here is to find set of all integer points which gives minimum

  • 0

The problem here is to find set of all integer points which gives minimum sum over all Manhattan distances from given set of points!

For example:

lets have a given set of points { P1, P2, P3…Pn }

Basic problem is to find a point say X which would have minimum sum over all distances from points { P1, P2, P3… Pn }.

i.e. |P1-X| + |P2-X| + …. + |Pn-X| = D, where D will be minimum over all X.

Moving a step further, there can be more than one value of X satisfying above condition. i.e. more than one X can be possible which would give the same value D. So, we need to find all such X.

One basic approach that anyone can think of will be to find the median of inputs and then brute force the co-ordinates which is mentioned in this post

But the problem with such approach is: if the median gives two values which are very apart, then we end up brute forcing all points which will never run in given time.

So, is there any other approach which would give the result even when the points are very far apart (where median gives a range which is of the order of 10^9).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:37:39+00:00Added an answer on June 3, 2026 at 4:37 am

    If the median gives you an interval of the order of 10^9 then each point in that interval is as good as any other.

    So depending on what you want to do with those points later on you can either return the range or enumerate points in that range. No way around it..

    Obviously in two dimensions you’ll get a bouding rectangle, in 3 dimensions a bounding cuboid etc..

    The result will always be a cartesian product of ranges obtained for each dimension, so you can return a list of those ranges as a result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched for a solution for my problem all over but I cannot find
I cannot find the solution for this problem, here is the simplified example: On
I tried to find a solution to my problem already in google and here
I suppose similar problem would have been discussed here, but I couldn't find it.
I can't seem to find solutions to this supposedly simple problem /bug, so here
i feel my beard growing while trying to find out the Problem here. Basic
I'm very confused as to what my problem is here. I've set up a
I'm working on a Project Euler problem which requires factorization of an integer. I
Very peculiar problem here, Simply the background image asset will display fine on ALL
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.