Skip to content

Commit dfb4f33

Browse files
committed
leetcode biweekly 93
1 parent 93dcb44 commit dfb4f33

5 files changed

+277
-0
lines changed

Atcoder/ABC/abc281A-Count Down.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
20+
int solve(){
21+
int n;
22+
cin>>n;
23+
for(int i=n;i>=0;i--){
24+
cout<<i<<endl;
25+
}
26+
return 0;
27+
}
28+
int main()
29+
{
30+
long long testCase=1;
31+
while(testCase--){
32+
solve();
33+
}
34+
return 0;
35+
}
36+
/* -----------------END OF PROGRAM --------------------*/
37+
/*
38+
* stuff you should look before submission
39+
* constraint and time limit
40+
* int overflow
41+
* special test case (n=0||n=1||n=2)
42+
* don't get stuck on one approach if you get wrong answer
43+
*/
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
/* ascii value
10+
A=65,Z=90,a=97,z=122
11+
*/
12+
13+
// Techniques :
14+
// divide into cases, brute force, pattern finding
15+
// sort, greedy, binary search, two pointer
16+
// transform into graph
17+
18+
int solve()
19+
{
20+
string s;
21+
cin>>s;
22+
if(s.size()==8){
23+
if(s[0]>='A' && s[0]<='Z' && s[7]>='A' && s[7]<='Z' && s[1]>='1' && s[1]<='9' && s[2]>='0' && s[2]<='9' && s[3]>='0' && s[3]<='9' && s[4]>='0' && s[4]<='9' && s[5]>='0' && s[5]<='9' && s[6]>='0' && s[6]<='9'){
24+
cout<<"Yes"<<endl;
25+
}
26+
else{
27+
cout<<"No"<<endl;
28+
}
29+
}
30+
else{
31+
cout<<"No"<<endl;
32+
}
33+
return 0;
34+
}
35+
int main()
36+
{
37+
long long testCase = 1;
38+
while (testCase--)
39+
{
40+
solve();
41+
}
42+
return 0;
43+
}
44+
/* -----------------END OF PROGRAM --------------------*/
45+
/*
46+
* stuff you should look before submission
47+
* constraint and time limit
48+
* int overflow
49+
* special test case (n=0||n=1||n=2)
50+
* don't get stuck on one approach if you get wrong answer
51+
*/
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
/* ascii value
10+
A=65,Z=90,a=97,z=122
11+
*/
12+
13+
// Techniques :
14+
// divide into cases, brute force, pattern finding
15+
// sort, greedy, binary search, two pointer
16+
// transform into graph
17+
18+
int solve()
19+
{
20+
long long n, t;
21+
cin>>n>>t;
22+
vector<long long> v(n);
23+
long long sum=0;
24+
for (long long i = 0; i < n; i++)
25+
{
26+
cin >> v[i];
27+
sum+=v[i];
28+
}
29+
t%=sum;
30+
if(t==0){
31+
cout<<n<<" "<<v[n-1]<<endl;
32+
}
33+
for(long long i=0;i<n;i++){
34+
if(t<=v[i]){
35+
cout<<i+1<<" "<<t<<endl;
36+
break;
37+
}
38+
else{
39+
t-=v[i];
40+
}
41+
}
42+
43+
return 0;
44+
}
45+
int main()
46+
{
47+
long long testCase = 1;
48+
while (testCase--)
49+
{
50+
solve();
51+
}
52+
return 0;
53+
}
54+
/* -----------------END OF PROGRAM --------------------*/
55+
/*
56+
* stuff you should look before submission
57+
* constraint and time limit
58+
* int overflow
59+
* special test case (n=0||n=1||n=2)
60+
* don't get stuck on one approach if you get wrong answer
61+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
typedef long long ll ;
6+
7+
8+
/* ascii value
9+
A=65,Z=90,a=97,z=122
10+
*/
11+
12+
/* --------------------MAIN PROGRAM----------------------------*/
13+
// to run ctrl+b
14+
const ll INF=1e18;
15+
const ll mod1=1e9+7;
16+
const ll mod2=998244353;
17+
// Techniques :
18+
// divide into cases, brute force, pattern finding
19+
// sort, greedy, binary search, two pointer
20+
// transform into graph
21+
22+
// Experience :
23+
// Cp is nothing but only observation and mathematics.
24+
25+
26+
//Add main code here
27+
28+
class Solution
29+
{
30+
public:
31+
int maximumValue(vector<string> &strs)
32+
{
33+
int maxo=0;
34+
for(auto x:strs){
35+
bool flag=false;
36+
for(auto y:x){
37+
if(y>='a' && y<='z'){
38+
flag=true;
39+
break;
40+
}
41+
}
42+
if(flag){
43+
maxo=max(maxo,(int)x.size());
44+
}
45+
else{
46+
maxo=max(maxo,(int)stoi(x));
47+
}
48+
}
49+
return maxo;
50+
51+
}
52+
};
53+
54+
/* -----------------END OF PROGRAM --------------------*/
55+
/*
56+
* stuff you should look before submission
57+
* constraint and time limit
58+
* int overflow
59+
* special test case (n=0||n=1||n=2)
60+
* don't get stuck on one approach if you get wrong answer
61+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
typedef long long ll;
6+
7+
/* ascii value
8+
A=65,Z=90,a=97,z=122
9+
*/
10+
11+
/* --------------------MAIN PROGRAM----------------------------*/
12+
// to run ctrl+b
13+
const ll INF = 1e18;
14+
const ll mod1 = 1e9 + 7;
15+
const ll mod2 = 998244353;
16+
// Techniques :
17+
// divide into cases, brute force, pattern finding
18+
// sort, greedy, binary search, two pointer
19+
// transform into graph
20+
21+
// Experience :
22+
// Cp is nothing but only observation and mathematics.
23+
24+
// Add main code here
25+
26+
class Solution
27+
{
28+
public:
29+
int maxStarSum(vector<int> &vals, vector<vector<int>> &edges, int k)
30+
{
31+
int n = vals.size();
32+
33+
vector<vector<int>> graph(n + 1);
34+
int maxo = INT_MIN;
35+
36+
for (auto x : edges)
37+
{
38+
graph[x[0]].push_back(vals[x[1]]);
39+
graph[x[1]].push_back(vals[x[0]]);
40+
}
41+
for(int i=0;i<n;i++){
42+
sort(graph[i].begin(),graph[i].end(),greater<int>());
43+
int sum=0;
44+
sum=vals[i];
45+
for(int j=0;j<k&&j<graph[i].size();j++){
46+
sum+=max(0,graph[i][j]);
47+
}
48+
maxo=max(maxo,sum);
49+
}
50+
return maxo;
51+
}
52+
};
53+
54+
/* -----------------END OF PROGRAM --------------------*/
55+
/*
56+
* stuff you should look before submission
57+
* constraint and time limit
58+
* int overflow
59+
* special test case (n=0||n=1||n=2)
60+
* don't get stuck on one approach if you get wrong answer
61+
*/

0 commit comments

Comments
 (0)