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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:47:10+00:00 2026-05-24T02:47:10+00:00

There is probably an efficient solution for this, but I’m not seeing it. I’m

  • 0

There is probably an efficient solution for this, but I’m not seeing it.
I’m not sure how to explain my problem but here goes…

Lets say we have one array with n integers, for example {3,2,0,5,0,4,1,9,7,3}.
What we want to do is to find the range of 5 consecutive elements with the “maximal minimum”…
The solution in this example, would be this part {3,2,0,5,0,4,1,9,7,3} with 1 as the maximal minimum.

It’s easy to do with O(n^2), but there must be a better way of doing this. What is it?

  • 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-05-24T02:47:12+00:00Added an answer on May 24, 2026 at 2:47 am

    If you mean literally five consecutive elements, then you just need to keep a sorted window of the source array.
    Say you have:
    {3,2,0,5,0,1,0,4,1,9,7,3}

    First, you get five elements and sort’em:

    {3,2,0,5,0, 1,0,1,9,7,3}
    {0,0,2,3,5} – sorted.

    Here the minimum is the first element of the sorted sequence.

    Then you need do advance it one step to the right, you see the new element 1 and the old one 3, you need to find and replace 3 with 1 and then return the array to the sorted state. You actually don’t need to run a sorting algorithm on it, but you can as there is just one element that is in the wrong place (1 in this example). But even bubble sort will do it in linear time here.

    {3,2,0,5,0,1, 0,4,1,9,7,3}
    {0,0,1,2,5}

    Then the new minimum is again the first element.

    Then again and again you advance and compare first elements of the sorted sequence to the minimum and remember it and the subsequence.

    Time complexity is O(n).

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

Sidebar

Related Questions

I'm new with Objective-C, so there probably is a simple solution to this. I
There is probably is simple fix for this but I currently have code similar
I'm using .Net 2.0 and this is driving me crazy but there's probably some
I'm sure there's an easy answer here and i'm just over-complicating things, but i
So far this is my solution. I wonder if there is some more elegant/efficient
I'm not too good with SQL and I know there's probably a much more
I'm new to the OOP paradigm, so there's probably a simple explanation for this
Question I'm creating a service for my app, but there's probably pritty simple thing
This is what I am trying to achieve but I'm not familiar with the
I still have a large number of floppies. On some of them there probably

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.