leetcode

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

1726.cpp (390B)


      1 class Solution {
      2   public:
      3     int tupleSameProduct(const vector<int> &nums) const {
      4         unordered_map<int, int> um;
      5         int res = 0;
      6         for (int i = 0; i < nums.size(); i++) {
      7             for (int j = i + 1; j < nums.size(); j++) {
      8                 const int prod = nums[i] * nums[j];
      9                 res += 8 * um[prod]++;
     10             }
     11         }
     12         return res;
     13     }
     14 };