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

  • SEARCH
  • Home
  • 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 8431761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:56:34+00:00 2026-06-10T05:56:34+00:00

Lets say I have four group A [ 0, 4, 9] B [ 2,

  • 0

Lets say I have four group

A [ 0, 4, 9]

B [ 2, 6, 11]

C [ 3, 8, 13]

D [ 7, 12 ]

Now I need one number from each group(i.e a new group) E [num of A,num of B, num of C, num of D], such that the difference between the maximum num in E and minimum num in E should be possible lowest.What type of problem is this ? which graph algorithm will be better to solve this kind of problem ?
Thanks in advance.

P.S : I’m trying to solve this in java and sorry for the unspecified title.

Edit :
Finally I’ve found what I’m actually looking for http://rcrezende.blogspot.in/2010/08/smallest-relevant-text-snippet-for.html

  • 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-10T05:56:35+00:00Added an answer on June 10, 2026 at 5:56 am
    1. Combine contents of every group into a single array. Each element of the array should be a pair of (number, group name).
    2. Sort this array by numbers.
    3. Advance two iterators, one after another. Move first iterator when elements of not every group are between these iterators. Move second iterator when there is an element of each group between these iterators. For details see this question.
    4. Minimum distance between iterators determine optimal resulting group (you only need to drop unneeded elements when there are several representatives of the same group there).

    Other algorithm:

    1. Sort elements of each group (if not sorted already).
    2. Put a pair (number, group name) for smallest elements of each group into priority queue (min-heap, priority=number).
    3. Remove smallest element from the queue and replace it with the next element from the same group.
    4. Repeat step 3 until no more elements are left in some group. Calculate max(queue) – min(queue) for each iteration and if it is smaller than any previous value, update the best-so-far resulting group.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four arrays that are coming in from the client. Let's say that
I have 5 pages - for ease lets say: one.html two.html three.html four.html five.html
lets say I have a list like so: ['one','two','three','four','five','six','seven','eight','nine'] and I want to experiment
Lets say I have 2 arrays . $arr1=array(foo=>bar, 1=>one, 2=>two); $arr2=array(h=>eich, 3=>three, 4=>four); By
lets say I have four PHP files as such: www/global.php <?php function doAwesomeStuff() {}
Let's say I have the following xml: <one> <two> <three> <three> foo </three> <four
Lets say I have a class A that is fairly simple like this -
lets say i have one array a = numpy.arange(8*6*3).reshape((8, 6, 3)) #and another: l
Let's say I have this list: my @list = qw(one two three four five);
Lets say I have string like this: String q = foo (one) bla (two)

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.