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 41861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:14:51+00:00 2026-05-10T15:14:51+00:00

You have an ascending list of numbers, what is the most efficient algorithm you

  • 0

You have an ascending list of numbers, what is the most efficient algorithm you can think of to get the ascending list of sums of every two numbers in that list. Duplicates in the resulting list are irrelevant, you can remove them or avoid them if you like.

To be clear, I’m interested in the algorithm. Feel free to post code in any language and paradigm that you like.

  • 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. 2026-05-10T15:14:52+00:00Added an answer on May 10, 2026 at 3:14 pm

    Edit as of 2018: You should probably stop reading this. (But I can’t delete it as it is accepted.)

    If you write out the sums like this:

    1 4  5  6  8  9 --------------- 2 5  6  7  9 10   8  9 10 12 13     10 11 13 14        12 14 15           16 17              18 

    You’ll notice that since M[i,j] <= M[i,j+1] and M[i,j] <= M[i+1,j], then you only need to examine the top left ‘corners’ and choose the lowest one.

    e.g.

    • only 1 top left corner, pick 2
    • only 1, pick 5
    • 6 or 8, pick 6
    • 7 or 8, pick 7
    • 9 or 8, pick 8
    • 9 or 9, pick both 🙂
    • 10 or 10 or 10, pick all
    • 12 or 11, pick 11
    • 12 or 12, pick both
    • 13 or 13, pick both
    • 14 or 14, pick both
    • 15 or 16, pick 15
    • only 1, pick 16
    • only 1, pick 17
    • only 1, pick 18

    Of course, when you have lots of top left corners then this solution devolves.

    I’m pretty sure this problem is Ω(n²), because you have to calculate the sums for each M[i,j] — unless someone has a better algorithm for the summation 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer This depends on how the sprite is going to be… May 11, 2026 at 1:45 pm
  • added an answer Freezing the gem itself is fairly straightforward - if Maran's… May 11, 2026 at 1:45 pm
  • added an answer On Vista+, MSHTA.exe has an embedded manifest, which takes priority… May 11, 2026 at 1:45 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.