Tech-Interview-Preparation icon indicating copy to clipboard operation
Tech-Interview-Preparation copied to clipboard

Adding a new code for a leetcode problem

Open Sinha199 opened this issue 5 years ago • 5 comments

This is the problem link 1577

Sinha199 avatar Oct 15 '20 12:10 Sinha199

I want to contribute on this project under hacktoberfest. please assign me in C++

YashJain2 avatar Oct 17 '20 10:10 YashJain2

Hi, can I work on this....

Sajal193 avatar Jun 20 '21 20:06 Sajal193

Hey, can I contribute?

Amisha328 avatar Jul 31 '21 05:07 Amisha328

class Solution { public: int numTriplets(vector& nums1, vector& nums2) {

int n1=nums1.size();
int n2=nums2.size();

map<long long ,int>mp1; map<long long ,int>mp2;

for(int i=0;i<n1;i++){
    long long  val=(long long)nums1[i]*(long long)nums1[i];
    mp1[val]++;
    
}

int count1=0,count2=0;

for(int i=0;i<n2;i++){ for(int j=i+1;j<n2;j++){ long long val=(long long)nums2[j]*(long long)nums2[i]; if(mp1.find(val)!=mp1.end()){ count1+=mp1[val]; } } }

for(int i=0;i<n2;i++){
   long long  val=(long long)nums2[i]*(long long)nums2[i];
    mp2[val]++;
    
}

for(int i=0;i<n1;i++){ for(int j=i+1;j<n1;j++){ long long val=(long long)nums1[i]*(long long)nums1[j]; if(mp2.find(val)!=mp2.end()){ count2+=mp2[val]; } } }

return count1+count2;

} };

saiteja-2731 avatar Sep 24 '21 10:09 saiteja-2731

Hello sir , please assign me this issue , i am pretty good in CP , currently i am a 3 start codder at codechef .

rko0211 avatar Oct 10 '22 18:10 rko0211