Sunday, December 11, 2011
Given an array of unsigned integers which is initially increasing (value of integers)and then decreasing find the maximum value in the array
Labels:Data
Amazon Interview
Subscribe to:
Post Comments
(
Atom
)
1 comment :
Use Binary Search. Find the mid element. if(Arr[mid] > Arr[Mid-1] && Arr[mid]>Arr[mid+1]) return mid. else if (Arr[mid] > Arr[mid-1] && Arr[mid]< Arr[mid+1]) low = mid+1
else high = mid-1.revise the search.
Post a Comment