-
Notifications
You must be signed in to change notification settings - Fork 1
/
snipate_code.cpp
462 lines (462 loc) · 11.1 KB
/
snipate_code.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
{
// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"1": {
"prefix": "cpplang",
"body": [
"#include <bits/stdc++.h>",
"#include <ext/pb_ds/assoc_container.hpp>",
"#include <ext/pb_ds/tree_policy.hpp>",
"",
"#define br \"\\n\"",
"#define ll long long",
"#define yes cout << \"YES\\n\"",
"#define no cout << \"NO\\n\"",
"",
"using namespace std;",
"using namespace __gnu_pbds;",
"template <typename T> // less -> set and less_equal -> multi_set",
"using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;",
"",
"class Solution",
"{",
"public:",
" void solve()",
" {",
" $0",
" }",
"};",
"signed main()",
"{",
" _Created : ${CURRENT_DATE} ${CURRENT_MONTH_NAME} ${CURRENT_YEAR} || ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}",
" // _File : ${TM_FILENAME}",
" // Writer : Md. Nazmus Sakib(engrsakib)",
" /* Enter your code here. Read input from STDIN. Print output to STDOUT */",
" // اللهم صل على سيدنا محمدن النبى الامى وآله وسلم",
" ios::sync_with_stdio(false);",
" cin.tie(NULL);",
" ll t = 1;",
" // cin >> t;",
" while (t--)",
" {",
" Solution obj;",
" obj.solve();",
" }",
" return 0;",
"}"
],
"description": "1"
},
"2 Singly Linked List": {
"prefix": "node",
"body": [
"class Node{",
" public:",
" int val;",
" Node *next;",
" Node(int val)",
" {",
" this->val = val;",
" this->next = NULL;",
" }",
"};"
],
"description": "2"
},
"3 Doubly Linked List": {
"prefix": "dnode",
"body": [
"class Node{",
" public:",
" int val;",
" Node *next;",
" Node *prev;",
" Node(int val)",
" {",
" this->prev = NULL;",
" this->val = val;",
" this->next = NULL;",
" }",
"};"
],
"description": "3"
},
"4 Vector Stack": {
"prefix": "vstack",
"body": [
"class my_stack",
"{",
" public:",
" vector <int> sakib;",
" void push(int val)",
" {",
" sakib.push_back(val);",
" }",
" void pop()",
" {",
" sakib.pop_back();",
" }",
" int top()",
" {",
" return sakib.back();",
" }",
" int size()",
" {",
" return sakib.size();",
" }",
" bool empty()",
" {",
" if(sakib.size() != 0) return false;",
" else return true;",
" }",
"};"
],
"description": "Vector Stack"
},
"5 List Stack": {
"prefix": "lsstack",
"body": [
"class my_stack",
"{",
" public:",
" list <int> sakib;",
" void push(int val)",
" {",
" sakib.push_back(val);",
" }",
" void pop()",
" {",
" sakib.pop_back();",
" }",
" int top()",
" {",
" return sakib.back();",
" }",
" int size()",
" {",
" return sakib.size();",
" }",
" bool empty()",
" {",
" if(sakib.size() != 0) return false;",
" else return true;",
" }",
"};"
],
"description": "5 List Stack"
},
"6 doubly linked list Stack": {
"prefix": "dscstack",
"body": [
"class Node{",
" public:",
" int val;",
" Node *next;",
" Node *prev;",
" Node(int val)",
" {",
" this->prev = NULL;",
" this->val = val;",
" this->next = NULL;",
" }",
"};",
"class my_stack",
"{",
" public:",
" Node *head = NULL;",
" Node *tail = NULL;",
" int sizes = 0;",
" void push(int val)",
" {",
" Node *new_Node = new Node(val);",
" sizes++;",
" if(head == NULL)",
" {",
" head = tail = new_Node;",
" return;",
" }",
" tail->next = new_Node;",
" new_Node->prev = tail;",
" tail = tail->next;",
" }",
" void pop()",
" {",
" sizes--;",
" Node *delete_Noed = tail;",
" tail = tail->prev;",
" if(tail == NULL)",
" {",
" head = NULL;",
" }",
" else",
" {",
" tail->next = NULL;",
" }",
" delete delete_Noed;",
" }",
" int top()",
" {",
" return tail->val;",
" }",
" int size()",
" {",
" return sizes;",
" }",
" bool empty()",
" {",
" if(sizes != 0) return false;",
" else return true;",
" }",
"};"
],
"description": "6 doubly linked list Stack"
},
"7 Queue singlily linked list": {
"prefix": "qsingly",
"body": [
"class Node{",
" public:",
" int val;",
" Node *next;",
" Node(int val)",
" {",
" this->val = val;",
" this->next = NULL;",
" }",
"};",
"class my_queye{",
" public:",
" Node *head = NULL;",
" Node *tail = NULL;",
" int count = 0;",
" void push(int val)",
" {",
" Node *new_Node = new Node(val);",
" count++;",
" if(head == NULL)",
" {",
" head = new_Node;",
" tail = new_Node;",
" return;",
" }",
" tail->next = new_Node;",
" tail = new_Node;",
" }",
" void pop()",
" {",
" Node *delete_Node = head;",
" count--;",
" head = head->next;",
" delete delete_Node;",
" if(head == NULL)",
" {",
" tail = NULL;",
" }",
" }",
" int fornt()",
" {",
" return head->val;",
" }",
" int sizes()",
" {",
" return count;",
" }",
" bool empty()",
" {",
" if(count == 0) return true;",
" else return false;",
" }",
"};"
],
"description": "7 Queue singlily linked list"
},
"8 Queue doubly linked list": {
"prefix": "qdoubly",
"body": [
"class Node{",
" public:",
" int val;",
" Node *next;",
" Node *prev;",
" Node(int val)",
" {",
" this->prev = NULL;",
" this->val = val;",
" this->next = NULL;",
" }",
"};",
"class my_queye{",
" public:",
" Node *head = NULL;",
" Node *tail = NULL;",
" int count = 0;",
" void push(int val)",
" {",
" Node *new_Node = new Node(val);",
" count++;",
" if(head == NULL)",
" {",
" head = new_Node;",
" tail = new_Node;",
" return;",
" }",
" tail->next = new_Node;",
" new_Node->prev = tail;",
" tail = new_Node;",
" }",
" void pop()",
" {",
" Node *delete_Node = head;",
" count--;",
" head = head->next;",
" delete delete_Node;",
" if(head == NULL)",
" {",
" tail = NULL;",
" return;",
" }",
" ",
" ",
" head->prev = NULL;",
" ",
" }",
" int fornt()",
" {",
" return head->val;",
" }",
" int sizes()",
" {",
" return count;",
" }",
" bool empty()",
" {",
" if(count == 0) return true;",
" else return false;",
" }",
"};"
],
"description": "8 Queue doubly linked list"
},
"9 Queue list": {
"prefix": "qlist",
"body": [
"class my_queye{",
" public:",
" list <int> sakib;",
" void push(int val)",
" {",
" sakib.push_back(val);",
" }",
" void pop()",
" {",
" sakib.pop_front();",
" ",
" }",
" int fornt()",
" {",
" return sakib.front();",
" }",
" int sizes()",
" {",
" return sakib.size();",
" }",
" bool empty()",
" {",
" return sakib.empty();",
" }",
"};"
],
"description": "9 Queue list"
},
"10 Binary Tree Node": {
"prefix": "bNode",
"body": [
"class Node{",
" public:",
" int val;",
" Node *left;",
" Node *right;",
" Node(int val)",
" {",
" this->val = val;",
" this->left = NULL;",
" this->right = NULL;",
" }",
"};"
],
"description": "10 Binary Tree Node"
},
"11 bainary tree input": {
"prefix": "binput",
"body": [
"Node *input_Node()",
"{",
" int val;",
" cin >> val;",
" Node *root;",
" if(val == -1) root = NULL;",
" else root = new Node(val);",
"",
" queue <Node *> q;",
" if(root) q.push(root);",
" while(!q.empty())",
" {",
" Node *p = q.front();",
" q.pop();",
" //Kaj Jeta amora korbo",
" int l, r;",
" cin >> l >> r;",
" Node *my_Left;",
" Node *my_Right;",
" if(l == -1) my_Left = NULL;",
" else my_Left = new Node(l);",
" if(r == -1) my_Right = NULL;",
" else my_Right = new Node(r);",
"",
" // Cannection",
" p->left = my_Left;",
" p->right = my_Right;",
"",
" //Chield PUSH",
" if(p->left) q.push(p->left);",
" if(p->right) q.push(p->right);",
" }",
" return root;",
"}"
],
"description": "11 bainary tree input"
},
"12 level Order print": {
"prefix": "blevelprint",
"body": [
"void level_order(Node *root)",
"{",
" queue <Node *> q;",
" q.push(root);",
" cout << \"Left to Right\" << endl;",
" while(!q.empty())",
" {",
" Node *f = q.front();",
" q.pop();",
"",
" cout << f->val << \" \";",
" //left to right",
" if(f->left) q.push(f->left);",
" if(f->right) q.push(f->right);",
" }",
"}"
],
"description": "12 level Order"
}
}