Tricky Interview Question:

Правка en1, от saketkumarsingh, 2023-09-17 19:29:28

I was asked this question in the interview round of a company: Given an array of integers of size atleast 3, such that a[0]>=a[1].... And a[n-2]<=a[n-1] such that it gives a v shape (i.e. first it’s decreasing then its increasing) find the minimum element in the array.

The interviewer asked to implement in O(log n) , if all the elements would have been distinct then I coded the approach using binary search but could not come up with a log n solution in case of duplicates. Can someone help me out?

Теги binary search, interview

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский saketkumarsingh 2023-09-17 19:31:46 46
en2 Английский saketkumarsingh 2023-09-17 19:30:17 1 (published)
en1 Английский saketkumarsingh 2023-09-17 19:29:28 534 Initial revision (saved to drafts)