Question: Write a function in Java that takes a input of a sorted array of integers (in ascending order) but roated at some point (only once)
Write a function in Java that takes a input of a sorted array of integers (in ascending order) but roated at some point (only once) and outputs the smallest element. For example, after a rotation a sorted array [0,1,2] could become [1,2,0]. The function should have at most log n time complexity.
The function is declared as follows:
Test 1:
Input: [1,2,0] Output: 0
Test 2:
Input: [4,5,0,1,2,3] Outputt: 0
Java public class Solution public int findsmallest int CJ arr) f Implement me
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
