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

2161. Partition Array According to Given Pivot

2000. Reverse Prefix of Word

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