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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:58:08+00:00 2026-06-03T14:58:08+00:00

I faced a question in an interview two days back regarding optimally finding the

  • 0

I faced a question in an interview two days back regarding optimally finding the maximum element in an array and I have query regarding that.

The array as described by interviewer consists of integer values which may repeat (not necessarily in consecutive places) and it also consists of two parts (One part may be empty) : First part in non-decreasing order, and second part in non-increasing order,i.e. if a[n] is an array consisting of n integer values, then, a[i]<=a[i+1],i in [1,m] and a[j]>=a[j+1],j in [m,n] and m lies somewhere between 1 and n inclusive. Now, they asked me to find the maximum value in the array in most efficient way.

I argued that as some elements may be repeated, I cannot element a search space using divide and conquer strategy. Had all the elements been distinct, we would be able to find maximum in lg n time using binary search. But there exists at least one input sequence (possibly when all elements are same) for which we at least need to have n-1 comparison before we can tell which element is maximum.

The interviewer asked me to think if I can impose some restriction on the input so that the problem can be solved in lg n time. I was not able to solve at that time and still thinking.

It would be helpful if you can help me in thinking.

  • 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-03T14:58:11+00:00Added an answer on June 3, 2026 at 2:58 pm

    The interviewer was trying to see if you know about ternary search: if you require that the parts are strictly increasing and then strictly decreasing, you’d be able to get an answer in Log3(N). So the additional requirement the interviewer was looking for is probably that duplicate entries, if any, should occur on different sides of the ascending-descending switchover point.

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

Sidebar

Related Questions

This is an interview question I faced recently. Given an array of 1 and
I have faced this question in my Interview as well. I do have many
This is also one of the interview question i have faced recently. Description :
I have faced the following interview question. Consider this function declaration: void quiz(int i)
Interview Question Phrased as: If you have a property name collision, how would you
Today I faced one question in interview. Is it possible to apply inheritance concept
I faced a rather simple question in an interview. Why do we use the
My question is really very important . When i program i have seen that
I saw that some others faced this similar problem. I have read and checked
I recently faced an interview question related to LINQ. What is the use of

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.