Skip to content

Commit

Permalink
Create 1726. Tuple with Same Product (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Feb 6, 2025
2 parents fc918bb + 6f1c9ad commit 5a20532
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 1726. Tuple with Same Product
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public:
int tupleSameProduct(vector<int>& nums) {
int ans = 0;
unordered_map<int, int> count;
for (int i = 0; i < nums.size(); ++i){
for (int j = 0; j < i; ++j)
ans += count[nums[i] * nums[j]]++ * 8;
}
return ans;
}
};

0 comments on commit 5a20532

Please sign in to comment.