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)


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