$ man dsa
A library of ways to think
Most problems are new; almost none are novel. Four years of contests taught me that behind thousands of problem statements sit a few dozen reusable moves. Sliding windows, disjoint sets, DP over subsets, binary lifting. And learning a move deeply beats skimming a hundred problems shallowly. This archive is that education, organized: 412 solutions across 19 topics, each kept because the problem was interesting enough to change how I approach the next one. It is also, indirectly, why a 21-hour production job became a 2-second one. Breadth-first search and bitsets were contest moves before they were production moves.
412 files
19 topics
clone it: git clone https://github.com/Arin016/Data-Structures-and-Algorithms.git
❯
412 of 412 files
▾▸STL76
10registration.cpp11commonabsolutediff.cpp12multimap.cpp13priorityqueue.cpp14candybag.cpp15reducethearray.cpp16set.cpp17studentandgrades.cpp18setoperations.cpp19towers.cpp1vector.cpp20concatenatearray.cpp21multiset.cpp22deque.cpp23indexedset.cpp24stlsearching.cpp25supportqueries.cpp26validparanthesis.cpp27countthepairs.cpp28sortbyrollnumber.cpp29intersetingame.cpp2productofdigits.cpp30meanvarimedianmode.cpp31Supportqueries2.cpp32NearestsmallerValues.cpp33largestrectangle.cpp34rainwater.cpp35SuperminimumSum.cpp36heightofsoilders.cpp37collissions.cpp38diversifythearray.cpp39rebuildoriginalarray.cpp3Buymaximumobjects.cpp40roundandround.cpp41maximumarea.cpp42gameondeque.cpp43molecularformula.cpp44AliceandBooks.cpp45setqueries.cpp46AddMul.cpp47ProductofLastK.cpp48SnapshotArray.cpp49sumpair.cpp4nextpermutation.cpp50FMBqueue.cpp51CircularQueue.cpp52Circulardeque.cpp53AllOneStringAlgoDesign.cpp54WordDictionaryTRIE.cpp55SearchSuggestionsSystemTRIE.cpp5stack.cpp6queue.cpp7queueusing2stack.cpp8map.cpp9goodsequence.cppalgodesigMEANMODEVARIANCEMEDIAN.cppalgorithmicdesign.cppcheckbalancedparanthesis.cppLFUcache.cppLRUcache.cppmaxofeverywindow.cppmedianusingtopkinsertremoveIdea.cppminstack.cppminstackADV.cppmonotonedeque.cppMultiset2TopKelementssummaintainence.cppnumberofsubarrayswithsumequaltox.cppparanthesisSTACK.cppphonepetest.cppRangeMaintainence1.cppRangeMaintainence2.cppsaminussbMaximiseyourscoreminimisetheopponentsscore.cppstackwithincrement.cppstlapplicationsmaximisenoofitems.cppTopKelementssummaintainence.cppwindowmaintainance.cpp
▾▸Dynamic Programming II57
01Knapsack.cpp0INFknapsack.cppADV_MergeElements.cppAutomata_finitestatemachines_Technique.cppBalancedBracketSequence.cppBrickColoring.cppBugsINCode.cppCherryPickupII.cppcleaningWindow.cppclimbingstairs.cppCoinChange.cppCoinChangeITERATIVE.cppCoins.cppCoinsALT.cppcountLIS.cppCountOfBinarystrings.cppDECIPHER.cppDECODINGS.cppDequeL.cppdestroyColoredGemstones.cppDIFFutility.cppDigitDP.cppDISTINCTsubsequences.cppDmagic.cppDPonGRIDUNIQUE.cppeditDistance.cppFROGII.cppGoogleOA_BS.cppGoogleOA_TREE.cppHARDsubsequence.cppisPalindromeQueryDP.cppJengaTower.cppKadaneTwist.cppKnapsackATC.cppKsubarrays.cppLargerString.cppLCSof2Strings.cppLCSof3strings.cppLIS.cppLISformII.cppLISnlogn.cpplongestcommonSUBSTRING.cppMakePalindrome.cppMakePalindromeALT.cppMatchSubseq.cppMatchSubstring.cppMatrixChainMultiplication.cppMaximisingTheCOST.cppmaximumAreaofsquare1.cppMaximumAreaRectangle.cppMaximumProductSubarray.cppMaximumScoreGRID.cppMaximumSUMinSUBGRID.cppMaximumXOR.cppMAXSubarraySum.cppMAXsumPATH2D.cppMergeElements.cpp
▾▸Graphs55
01BFS.cpp1DFS.cpp1Dijkstra.cpp2D_Bfs.cpp2D_Dfs.cppAllpairsShortestPath.cppArticulationPoints.cppBellmanFord.cppBFS.cppBFStopoOrdering.cppbipartiteCheck.cppBuildingRoads.cppburnthemAll.cppCandyCrush.cppcolorTree.cppcompletethegame.cppconnectedCMPsize.cppDFSGraphGirth.cppDFSTopoOrdering.cppDIRECTEDgraphCYCLE.cppeasygraphqueries.cppEdgeCompression.cppEdgeReverse.cppFLOODFILL.cppFloydWarshall.cppFMCGSUPPLY.cppGothamRises.cppGraphGirth.cppinfectedPeople.cppKNIGHTS.cppKwallBreak.cppminimisingLabels.cppminimumWalltoBreak.cppMODELLING.cppMSSP.cppMULTIGRAPH.cppnodeandfuelleft.cppNOofwaysDIRECTEDgraph.cpponeEdge.cppOnePiece.cppPOLICE.cppPractice_ArticulationPoints.cppPRIORITYQUEUECUSTOM.cpproundtrip.cpproundtrip2.cppSCC.cppShortestDiswithCITYcost.cppshortestPath1.cppshortestPath2.cppSmallestPermutation.cppSNAKE&Ladders.cppStringConversionGraphModelling.cppThreeStates.cpptopoorderingDP.cppUNDIRECTEDgraphCYCLE.cpp
▾▸Dynamic Programming42
MinimiseTHEmaximum.cppminNoofBREAKS+palindrome.cppMOCKTEST3.cppMONOTONEDEQUE.cppMountainArrayII.cppmultipleTESTcases.cppNOadjacentKnapsack.cppNoofwaysinGRID.cppNoofwaysinGRID2.cppNoofwaysinGRID3.cppPalindromicPaths.cpppileGame.cpppileGameITERATIVE.cppPolygonTriangulation.cppPREFIXSUMOPTIMISATION.cppPrimeSubsequences.cppPRINTSOLUTION.cppRemovalGame.cppRemoveBoxes.cppRemoveMarbles.cppRockPaperScissors.cppRodCuttingProblem.cppScrambledString.cppSHORTESTCOMMONSUPERSEQUENCE.cppSHORTESTUNCOMMONSUBSEQUENCE.cppSKY.cppSLiderDJMIX.cppSLiderDJMIXITERATIVE.cppSORTINGdp.cppSortThestrings.cppSPACEOptimisation.cppSTATEROTATIONKnapsack.cppStoneGame.cppSubtarctionGame.cppSumPartition.cpptemppp.cpptesting.cppTRAVEL_optimisation.cpptreedp.cppVacationATC.cppweightedJOBScheduling.cppWordBreak.cpp
▾▸Trees27
1TREEDP.cpp2TREEDP.cpp3TREEDP.cpp4TREEDP.cpp5TREEDP.cpp6TREEDP.cpp7TREEDP.cpp8TREEDP.cpp9TREEDP.cppAADV_DFS.cppADV_DFS.cppbinaryLifting.cppCentreofaTREE.cppCentroidTREE.cppContributionTechniqueSUMOFDISTANCES.cppdiameterofTREE.cppEulerTour.cppGCDTreepathAggregate.cppLCA.cppLCAtwist.cppmaximumCostTree.cppNOofDiameters.cpppartialSumsonTrees.cppsimplePrefixsums.cppSUMTreepathAggregate.cpptreebasics.cpptreeTEMPLATE.cpp
▾▸Segment Tree19
11BracketQueries.cpp11EvenOddQueries.cpp11MergeSortTree.cpp11MIN.cpp11MinandCNTmin.cpp11PrefixSumQueries.cpp11SubarraySumQueries.cpp11XOR.cppbasickthSegTree.cppbasickthsegtree1.cppBasicKthSTD_orderofHeights.cppbasicLAZYdouble.cppcoordinatecompression.cppDISTINCTinLR.cppDPAndCoordinateCompression.cppfirsteleGREATEREQUALTOK.cppNUmofELElessthanorEqualtoKinLR.cppSalaryQueries.cppSPL_kthsmallestAi_inLR.cpp
▾▸Binary search17
2dBSsumvariation.cppABC362d.cppatomicitemcontributions.cppBSonRealdomain.cppcheckonslopeandeliminatehalves.cppclasroomlinearcheckfunc.cppcolorBalls.cppmaximisethefraction.cppmaximumsubarrayfilledwithzero.cppmaxlensubarraywithOnewithKflips.cppmedianofsubarray.cppmultiplicationtable.cppnumberandsumofdigit.cpppainterpartition.cppplacingKpointsonnline.cppsublinear.cppvectorbyrefvsbyvalue.cpp
▾▸Recursion and Backtracking15
▾▸two pointers14
3sumtemplate.cppcntSUBARRAYsumlessthanequaltok.cppcontainerwithmaximumwater.cppcountDistcharinsubstrings.cppcountUniquecharinSubstrings.cppkoddnumbers.cpplongestSubarraywithalldistinct.cppminimumpenalty.cppoptimisedkdistelementsusingarrayanddistcnt.cppshortestSubarray.cpptemplatetwopointers.cpptesting.cpptesting997.cppthreesum.cpp
▾▸prefix and partial sums13
▾▸bit manipulation12
▾▸Disjoint Set Union12
▾▸number theory12
▾▸Tries12
▾▸String algorithms11
▾▸sweep line9
▾▸meet in the middle6
▾▸Divide and conquer2
▾▸Modular Arithmetic1
01
why a library, not a streak
Solved problems are kept as references — each one earns its place by changing how the next problem gets read, not by filling a calendar.
02
from contest to production
The 21-hour SoD job became a 2-second one with moves this archive teaches: breadth-first search over org hierarchies, bitsets for permission comparison.
03
how to use it
Pick a topic, solve until the pattern becomes reflex, then move on. Every file below links to the actual code in the repo.