Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

public class Solution { public int findMin(int[] num) { for(int i=1; i<num.length; i++) { if(num[i] < num[i-1]) return num[i]; } return num[0]; } }

because O(log(n)) is better than O(n), especially on an interview.

cool now I understand. Thanks

The more efficient way would be using binary search to achieve O(logn) complexity. O(n) solution is too obvious.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.