category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

1814. Count Nice Pairs in an Array

Implementation ```cpp using ll = long long int; const int mod = int(1e9 + 7); class Solution { public: int rev(int n){ int revNum = 0; while(n) revNum = revNum * 10 + (n % 10), n /= 10; return revNum; } int countNicePairs(vector& nums) { ll count = 0; map<int, ll> mp; for(const auto& num : nums) mp[num - rev(num)]++; for(const auto& pair : mp) count = (count + (pair.second * (pair.second - 1)) / 2) % mod; return count; } }; ``` </details>