Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- int fourSumCount(vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D) {
- int n = (int)A.size();
- unordered_map<int,int>mp;
- for( int i=0;i<n;i++ )
- {
- for(int j=0;j<n; j++ )
- {
- mp[A[i] + B[j]]++;
- }
- }
- int ans = 0;
- for( int i=0;i<n;i++ )
- {
- for(int j=0;j<n; j++ )
- {
- if(mp.count(-C[i]-D[j]))ans+=mp[-C[i]-D[j]];
- }
- }
- return ans;
- }
- };
Add Comment
Please, Sign In to add comment