Skip to content

Commit 5a20532

Browse files
authored
Create 1726. Tuple with Same Product (#708)
2 parents fc918bb + 6f1c9ad commit 5a20532

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

1726. Tuple with Same Product

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int tupleSameProduct(vector<int>& nums) {
4+
int ans = 0;
5+
unordered_map<int, int> count;
6+
for (int i = 0; i < nums.size(); ++i){
7+
for (int j = 0; j < i; ++j)
8+
ans += count[nums[i] * nums[j]]++ * 8;
9+
}
10+
return ans;
11+
}
12+
};

0 commit comments

Comments
 (0)