Find Minimum in Rotated Sorted Array LeetCode solution in C++
1class Solution {2public:3int findMin(vector<int> &nums) {4int result = -1;5int first = nums[0];67// check the array for rotated point when it is obtained break the loop and8// assign result as rotation point9for (int i = 1; i < nums.size(); i++) {10if (nums[i - 1] > nums[i]) {11result = nums[i];12break;13}14}15// if the array is not sorted return first element16if (result == -1) {17return first;18}19return result;20}21};