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

67. Add Binary

160. Intersection of Two Linked Lists

1769. Minimum Number of Operations to Move All Balls to Each Box