Skip to content

Commit f605c7d

Browse files
author
sunilmaurya
committed
added multiple code files
1 parent 89166f6 commit f605c7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2867
-271
lines changed

.DS_Store

14 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
Coding-ninjas-competitive
77
Competitive-Coding
88
Dynamic-Programming
9+
leetcode_company_wise_questions-master
10+
comptetive-programming_interview-resource
11+
coding template by other

.vscode/c_cpp_properties.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

Untitled-1.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
// 7
4+
// 7 3 9 8 7 2 1
5+
// output
6+
// 1 2 7 8 9 3 7
7+
int main(){
8+
9+
int n;
10+
cin>>n;
11+
int arr[n];
12+
13+
for(int i=0;i<n;i++){
14+
cin>>arr[i];
15+
}
16+
17+
for(int i=n-1;i>=0;i--){
18+
cout<<arr[i]<<" ";
19+
}
20+
return 0;
21+
}

basics/binaryTree.cpp

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int dp[2000][2000]={0};
5+
int dp1[2000][2000]={0};
6+
int main() {
7+
// your code goes here
8+
// cout<<"sunil"<<dp[100][10];
9+
10+
int i = 0, j = 0; // i counts rows, j counts columns
11+
12+
int n = 2000;
13+
int k=1;
14+
for(int p=0;p<2000;p++){
15+
int i=0;
16+
int j=p;
17+
while(j>=0){
18+
dp[i][j]=k++;
19+
dp1[i][j]=dp[i][j];
20+
i++;
21+
j--;
22+
}
23+
}
24+
for(int i=1;i<1000;i++){
25+
dp[0][i]=dp[0][i]+dp[0][i-1];
26+
}
27+
for(int i=1;i<1000;i++){
28+
dp[i][0]=dp[i][0]+dp[i-1][0];
29+
}
30+
31+
for(int i=1;i<1000;i++){
32+
for(int j=1;j<1000;j++){
33+
int x=dp[i-1][j];
34+
int y=dp[i][j-1];
35+
dp[i][j]=dp[i][j]+max(x,y);
36+
// cout<<dp[i][j]<<" ";
37+
}
38+
// cout<<"\n";
39+
}
40+
int t;
41+
cin>>t;
42+
while(t--){
43+
int x1,y1,x2,y2;
44+
cin>>x1>>y1>>x2>>y2;
45+
x1--;y1--;x2--;y2--;
46+
47+
if(x2>=x1 && y2>=y1){
48+
int intial=dp[x1][y1];
49+
int final1=dp[x2][y2]-intial+dp1[x1][y1];
50+
cout<<final1<<"\n";
51+
}else{
52+
cout<<0<<"\n";
53+
}
54+
55+
}
56+
return 0;
57+
}
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
// user
70+
// id
71+
72+
73+
74+
75+
// url_store
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
// // 5
103+
// // 8 2
104+
// // 6 5 9 4
105+
106+
107+
// // bool order=true l->r
108+
// // false r->l
109+
110+
111+
// // queue-> 6 5 9 4
112+
113+
// // queue_size 4
114+
115+
// // order=true
116+
117+
// // print-> 5 2 8 6 5 9 4
118+
119+
120+
// // 5 2 8 6 5 9 4
121+
// // struct binaryTree
122+
// // {
123+
// // binaryTree *left;
124+
// // binaryTree * right;
125+
// // int val;
126+
// // };
127+
128+
// void zigzag(TreeNode *root){
129+
// if(root==NULL)return;
130+
131+
// bool order=true;
132+
133+
// queue<TreeNode *>q;
134+
// q.push(root);
135+
136+
// while(q.size()){
137+
138+
// int queue_size=q.size();
139+
// vector<int>levelStore;
140+
141+
// while(queue_size--){
142+
143+
// TreeNode *topElement= q.front();
144+
// q.pop();
145+
146+
// levelStore.push_back(topElement->val);
147+
148+
// if(topElement->left){
149+
// q.push(topElement->left);
150+
// }
151+
152+
// if(topElement->right){
153+
// q.push(topElement->right);
154+
// }
155+
// }
156+
// if(order){
157+
// for(int i=0;i<n;i++){
158+
// cout<<levelStore[i]<<" ";
159+
// }
160+
// }
161+
// else{
162+
// for(int i=n-1;i>=0;i--){
163+
// cout<<levelStore[i]<<" ";
164+
// }
165+
// }
166+
// order = !order;
167+
// }
168+
169+
// }

basics/factorial_large.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include<iostream>
2+
#include<vector>
3+
using namespace std;
4+
5+
int main() {
6+
// freopen("i.txt", "r", stdin);
7+
8+
int n=4000;
9+
vector<char>ans;
10+
ans.push_back('1');
11+
for(int i=1;i<=n;i++){
12+
int rem=0;
13+
14+
for(int j=0;j<ans.size();j++){
15+
int k=ans[j]-'0';
16+
rem = rem+ k*i;
17+
ans[j]=(char)(rem%10 + '0');
18+
rem=rem/10;
19+
}
20+
while(rem){
21+
ans.push_back((char)(rem%10 + '0'));
22+
rem=rem/10;
23+
}
24+
}
25+
cout<<ans.size()<<"\n";
26+
for(int i=0;i<ans.size();i++){
27+
cout<<ans[i];
28+
}
29+
cout<<"\n";
30+
int sum=0;
31+
for(int i=0;i<ans.size();i++){
32+
sum=sum+ans[i]-'0';
33+
}
34+
cout<<sum<<"\n";
35+
cout<<endl;
36+
37+
return 0;
38+
}
39+

0 commit comments

Comments
 (0)