for Robot Artificial Inteligence

61. Search in Rotated Sorted Array

|

class Solution {
public:
    int search(vector<int>& nums, int target) {
        int i = 0;
        for(auto k : nums)
        {
            i++;
            if(k==target)
                return i-1;
        }
        return -1;

    }
};

Comments