File tree Expand file tree Collapse file tree
Linked List Imp Coding Question for your Interview/From LeetCode/2-add-two-numbers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ class Solution {
3030 l2 = l2->next ;
3131 }
3232
33- sum += carry;
33+ sum =sum+carry;
34+ //
3435 carry = sum / 10 ;
3536 ListNode* node = new ListNode (sum%10 );
3637 temp->next = node;
Original file line number Diff line number Diff line change 1+ // https://codeforces.com/contest/1722/problem/C
2+
3+ #include < bits/stdc++.h>
4+ #include < map>
5+ #include < iterator>
6+ using namespace std ;
7+
8+ int main () {
9+ int t;
10+ cin>>t;
11+ while (t--){
12+ int n;
13+ cin>>n;
14+ map<string,int >mp;
15+ vector<vector<string>>v;
16+ // vector of vector
17+ for (int i=0 ;i<3 ;i++){
18+ vector <string> s;
19+ for (int j=0 ;j<n;j++){
20+ string ss;
21+ cin>>ss;
22+ mp[ss]++;
23+ s.push_back (ss);
24+
25+ }
26+ v.push_back (s);
27+
28+ }
29+ vector<int >v1 (3 ,0 );
30+ for (int i=0 ;i<3 ;i++){
31+ for (int j=0 ;j<n;j++){
32+ if (mp[v[i][j]]==1 ) v1[i]=v1[i]+3 ;
33+ else if (mp[v[i][j]]==2 ) v1[i]=v1[i]+1 ;
34+ }
35+ }
36+ for (int i=0 ;i<3 ;i++){
37+ cout<<v1[i]<<" " ;
38+ }
39+ cout<<endl;
40+
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments