We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 08b82ac commit 6d6b8c8Copy full SHA for 6d6b8c8
Sorted and Rotated Minimum
@@ -0,0 +1,19 @@
1
+class Solution {
2
+ public:
3
+ int findMin(vector<int>& arr) {
4
+ // complete the function here
5
+ int n = arr.size();
6
+ if(n == 1)
7
+ {
8
+ return arr[0];
9
+ }
10
+ for(int i = 0; i < n; i++)
11
12
+ if(arr[(i-1+n)%n] > arr[i] && arr[i] < arr[(i+1)%n])
13
14
+ return arr[i];
15
16
17
+ return -1;
18
19
+};
0 commit comments