leetcode

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

2441.cpp (331B)


      1 class Solution {
      2   public:
      3     int findMaxK(const vector<int> &nums) const {
      4         static uint8_t us[2001];
      5         int res = -1;
      6 
      7         memset(us, 0x00, sizeof(us));
      8         for (const int n : nums) {
      9             if (us[-n + 1000]) res = max(res, abs(n));
     10             us[n + 1000] = 1;
     11         }
     12 
     13         return res;
     14     }
     15 };