9ms c++ set 2 lines


  • 0
    T
    class Solution {
    public:
        bool search(vector<int>& nums, int target) {
            set<int> s(nums.begin(),nums.end());
            if (s.find(target)!=s.end()) return true;else return false;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.