leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

3289.cpp (354B)


      1 class Solution {
      2   public:
      3     vector<int> getSneakyNumbers(vector<int> &nums) const {
      4         vector<int> res;
      5 
      6         for (const int n : nums) {
      7             const int m = n < 0 ? -n - 1 : n;
      8             if (nums[m] < 0)
      9                 res.push_back(m);
     10             else
     11                 nums[m] = -nums[m] - 1;
     12         }
     13 
     14         return res;
     15     }
     16 };