Skip to content

Commit 42b1f40

Browse files
find pair whose sum is equal to target sum
1 parent ae27dd8 commit 42b1f40

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

Codevita/2020/Zone 1/Maximum Prize.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
1212
o All your opponents are standing inone line next to each other i.e. the order of opponents is fixed
1313
14-
o Your first task is to choose a suitable opponent from this lineoWhen you choose one opponent from that line, he steps out of the line and fights you.
14+
o Your first task is to choose a suitable opponent from this line
15+
16+
o When you choose one opponent from that line, he steps out of the line and fights you.
1517
1618
o After you beat him, you get to decide how your prize money for winning against him will be calculated
1719

Codevita/2020/Zone 2/Path Through Graph.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Since there are 2 edges in this graph, output will be 2.
9595

9696
#include <bits/stdc++.h>
9797
using namespace std;
98-
98+
9999
#define int long long
100100
#define endl '\n'
101101

@@ -109,20 +109,20 @@ int get(int x)
109109
}
110110

111111
void sol()
112-
{
112+
{
113113
int x,y;
114114
cin>>x>>y;
115115
if(x<y)swap(x,y);
116116
if(x==y){cout<<0;return;}
117117
map<int,int> m;
118-
118+
119119
int c=0;
120120
while(x!=1)
121121
{
122122
c++;
123123
x=get(x);
124124
m[x]=c;
125-
}
125+
}
126126
c=0;
127127
while(!m.count(y))
128128
{
@@ -132,8 +132,8 @@ void sol()
132132
cout<<c+m[y];
133133
}
134134
int32_t main()
135-
{
135+
{
136136
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
137137
sol();
138138
return 0;
139-
}
139+
}

DP/Hashing/find pair whose sum is equal to target sum.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'''
2-
find pair whose sum is equal to target sum
3-
'''
1+
''' find pair whose sum is equal to target sum '''
2+
43
from collections import defaultdict
54
n=int(input())
65
a=defaultdict(list)

0 commit comments

Comments
 (0)