Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c71e9d

Browse files
Create 1726. Tuple with Same Product.cpp
1 parent e4cf4ac commit 8c71e9d

File tree

1 file changed

+16
-0
lines changed

1 file changed

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /