Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a new code for a leetcode problem #21

Open
Sinha199 opened this issue Oct 15, 2020 · 5 comments
Open

Adding a new code for a leetcode problem #21

Sinha199 opened this issue Oct 15, 2020 · 5 comments

Comments

@Sinha199
Copy link

This is the problem link 1577

@YashJain2
Copy link

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

phdtrong added a commit to phdtrong/Tech-Interview-Preparation that referenced this issue Apr 14, 2021
phdtrong added a commit to phdtrong/Tech-Interview-Preparation that referenced this issue Apr 15, 2021
Create Conditional Triplet.cpp for a Leetcode problem sastava007#21
@Sajal193
Copy link

Hi, can I work on this....

@Amisha328
Copy link

Hey, can I contribute?

@saiteja-2731
Copy link

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;

}
};

@rko0211
Copy link

rko0211 commented Oct 10, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants