A collection of code snippets for competitive programmers, written in C++ for vscode.
Many times this happens in competitive programming competitions that you've figured out an algorithm for the solution of the problem, which happens to be a standard algorithm. How helpful would it be to have snippets for commonly used concepts/algorithms in competitive programming in that situation, to provide you an edge over fellow competitors as using snippets will improve your accuracy, speed and hence rank!
This repository provides extension for vscode editor which enables vscode users to use c++ coding snippets of algorithms while doing competitive programming.
Harsh Chandravanshi: Portfolio
- C++ (.cpp, .c++)
- C (.c)
Every space inside { }
and ( )
means that this is pushed into next line :)
$
represent each step after tab
.
Prefix | Uses/Method |
---|---|
cpp |
CP Starter Template |
c++ |
C++ Starter Template |
dsa |
DSA Specific Starter Template |
kickstart |
Google KickStart C++ Template |
Prefix | Uses/Method |
---|---|
forn |
For loop with n size |
whilen |
While loop with n size |
couta |
Print elements of array of n size |
coutv |
Print elements of vector |
autov |
Print element of vector with auto |
Prefix | Uses/Method |
---|---|
inai |
Taking input in n size int array |
inal |
Taking input in n size long long int array |
invi |
Taking input in n size int vector |
invl |
Taking input in n size long long int vector |
Prefix | Uses/Method |
---|---|
gcd |
Greatest Common Divisor |
maxll |
Maximum Function with long long int |
minll |
Minimum Function with long long int |
isPowerOfTwo |
Check number is power of two |
isPrime |
Check number is prime |
primeFactors |
return all prime factors |
countDivisors |
count of all divisors |
divisorFunction |
sum of all divisors |
nFactorial |
return n! |
nFactorialMOD |
return n!%mod |
nextPowerOfTwo |
next power of two |
prevPowerOfTwo |
prev power of two |
xpowery |
x^y |
xpoweryMOD |
(x^y)%mod |
sieve |
sieve of eratosthenes |
lcm |
Least Common Multiple |
combinatorics |
Combinatorics |
Prefix | Uses/Method |
---|---|
adjMatrix |
Adjacency Matrix in Graph |
adjList |
Adjacency List in Graph |
bfs |
BFS in Graph |
dfs |
DFS in Graph |
topoBfs |
Topological BFS in Graph |
topoDfs |
Topological DFS in Graph |
isCycleDfs |
Is Cycle is Present in Graph using DFS |
isCycleBfs |
Is Cycle is Present in Graph using BFS |
shortesPathDAG |
Shortest Path Direct Acyclic Graph |
dijkstra |
Dijkstra shortest path algorithm |
bellmanFord |
Bellman Ford shortest path algorithm |
Prefix | Uses/Method |
---|---|
tstruct |
Tree Structure |
inorder |
Tree Inorder |
preorder |
Tree Preorder |
postorder |
Tree Postorder |
levelOrder |
Level Order Traversal Tree |
treeSize |
Tree Size |
treeHeight |
Tree Height |
treeDiaSimple |
Tree Diameter Simple |
treeDiaOpt |
Tree Diameter Optimized |
treeSum |
Tree Node Sum |
treeMax |
Tree Node Maximum |
treeLeftView |
Tree Left View |
treeRightView |
Tree Right View |
isBalancedSimple |
Tree Balanced or Not Simple |
isBalancedOpt |
Tree Balanced or Not Optimized |
flatten |
Flatten Binary Tree |
Prefix | Uses/Method |
---|---|
insBst |
Insert in BST |
delBst |
Delete in BST |
searchBst |
Search in BST |
constructBst |
Construct BST |
isBst |
Check the given tree is BST or not |
sortArrToBst |
Sorted array to Bst |
isIdentical |
Is Bst identical or nor |
zigzagTraversal |
zigzagTraversal Bst |
Prefix | Uses/Method |
---|---|
palindrome |
palindrome-String |
pangram |
pangram-string |
anagram |
anagram-strings |
strtodec |
stringtodecimal |
dectostr |
decimaltostring |
kmp |
occurences of pattern in a string |
distict_characters |
count of unique characters in a string |
lc_subsequence |
longest common subsequence of two strings |
lc_substring |
longest common substring of two strings |
Prefix | Uses/Method |
---|---|
insort |
Insertion Sort |
bubsort |
Bubble Sort |
selsort |
Selection Sort |
mersort |
Merge Sort |
qsort |
Quick Sort |
Prefix | Uses/Method |
---|---|
bsearch |
Binary Search |
No Issues
Initial release with the snippets on above topics with their prefixes.
Enjoy!