81. Search in Rotated Sorted Array II

// Approach 1 Linear Search

 class Solution {

public:

    bool search(vector<int>& nums, int target) {

        

        for(int i=0;i<nums.size();i++){

            if(nums[i]==target)

                return true;

        }

};


Approach 2 Binary Search

First find pivot and select the portion where to move

Comments

Popular posts from this blog

160. Intersection of Two Linked Lists

67. Add Binary

88. Merge Sorted Array