알고리즘 문제풀이/LeetCode

LeetCode 81번 - Search in Rotated Sorted Array II

leetcode.com/problems/search-in-rotated-sorted-array-ii/submissions/

 

Search in Rotated Sorted Array II - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

class Solution {
public:
    int search(vector<int>& nums, int target) {

       set<int> s(nums.begin(),nums.end());
           if(s.count(target)){
               return true;
           }
                
        return false;
        
    }
};

 

target을 찾을수 있으면 true, 

못찾으면 false이다. 

다소 쉬운 문제라, 다른 설명은 생략하도록 하겠다.