text: #include <gtest/gtest.h>
  #include <iostream>
  #include <unordered_map>
  #include <vector>
  
  using namespace std;
  
  /**
   * This file is generated by leetcode_add.py
   *
   * 1010.
   *       Pairs of Songs With Total Durations Divisible by 60
   *
   * ––––––––––––––––––––––––––––– Description –––––––––––––––––––––––––––––
   *
   *   You are given a list of songs where the iᵗʰ song has a duration of
   *   ‘time[i]’
   *   Return “the number of pairs of songs for which their total duration in
   *   seconds is divisible by” ‘60’ . Formally, we want the number of
   *   indices ‘i’ , ‘j’ such that ‘i < j’ with ‘(time[i] + time[j]) % 60 =
   *   0’ .
   *
   * ––––––––––––––––––––––––––––– Constraints –––––––––––––––––––––––––––––
   *
   *   • ‘1 ≤ time.length ≤ 6 × 10⁴’
   *   • ‘1 ≤ time[i] ≤ 500’
   *
   */
  
  struct q1010 : public ::testing::Test {
    // Leetcode answer here
    class Solution {
     public:
      int numPairsDivisibleBy60(vector<int> &time) {
        int                     res = 0;
        unordered_map<int, int> hash;
        for (auto &x : time) x %= 60;
        for (const auto &x : time) {
          int f = 60 - x;
          if (f == 60 && hash.count(0)) res += hash[0];
          else if (hash.count(f))       res += hash[f];
          ++hash[x];
        }
        return res;
      }
    };
  
    class Solution *solution;
  };
  
  TEST_F(q1010, sample_input01) {
    solution = new Solution();
    vector<int> time = {30, 20, 150, 100, 40};
    int exp = 3;
    int act = solution->numPairsDivisibleBy60(time);
    EXPECT_EQ(act, exp);
    delete solution;
  }
  
  TEST_F(q1010, sample_input02) {
    solution = new Solution();
    vector<int> time = {60, 60, 60};
    int exp = 3;
    int act = solution->numPairsDivisibleBy60(time);
    EXPECT_EQ(act, exp);
    delete solution;
  }