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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:27:17+00:00 2026-06-18T09:27:17+00:00

Assuming we have a list containing integers and we need to find min &

  • 0

Assuming we have a list containing integers and we need to find min & max. What is the best way to do it ? I can think of following :

  1. If number of reads are much higher than writes; keep the list in sorted manner. Whenever a number is added; add it in sorted manner.
    Now to get min and max we can just get first and last element of this
    list.

  2. If number of writes are higher than reads; iterate on the list and return result. But this is O(n) which looks to be expensive.

Is there any other better way ?

  • 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-18T09:27:18+00:00Added an answer on June 18, 2026 at 9:27 am

    Assuming you can observe any mutation to the list, you could store (cache) the min and max values and possibly update the cached values when a number is added / removed. At this point, the order of the list doens’t matter.

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

Sidebar

Related Questions

Assuming I have the following string array: string[] str = new string[] {max, min,
Assuming I have an object A containing // ... private List<double> someList = new
Assuming I have the following list: IList<string> list = new List<string>(); list.Add(Mouse); list.Add(Dinner); list.Add(House);
Assuming I have a list of objects that have the following fields parent value
Assuming I have a list of financial transactions, I have a need to execute
assuming I have the following array: views = [ { :user_id => 1, :viewed_at
Assuming i have a post model with created_at, title, and id. How can i
Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
Assuming I have a comments model and a posts model, What code can I
I have a data structure containing a list of objects, like this: class A

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.