├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug.yml │ ├── config.yml │ ├── custom.yml │ ├── documentation.yml │ ├── feature.yml │ └── idea.yml ├── PULL_REQUEST_TEMPLATE.md ├── release-drafter.yml └── workflows │ ├── autolabel.yml │ ├── codeql.yml │ ├── dependency-review.yml │ ├── deploy.yml │ ├── issue_close_open.yml │ ├── lighthouse-report.yml │ ├── lighthouserc.json │ ├── pr_merge.yaml │ ├── pr_raise.yml │ ├── pr_validation.yml │ ├── release.yml │ ├── stale.yml │ └── test-deploy.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── admin └── scripts │ ├── formatLighthouseReport.js │ └── package.json ├── babel.config.js ├── blog ├── 20-most-important-coding-pattern.md ├── Common-Recursion-Patterns.md ├── Exploring-Graph-Algorithms.md ├── Getting-started-with-array-data-structure.md ├── Kadanes-algorithm.md ├── Recursion-vs-Iteration.md ├── Understanding-Graph-Representation.md ├── a-very-useful-data-structure-linked-lists.md ├── a-very-useful-data-structure-string.md ├── authors.yml ├── balancing-speed-and-memory-A-Guide-to-Time-and-Space-Complexity.md ├── bloom-filter.md ├── comparing-sortings.md ├── language-matters-your-path-to-dsa-success-starts-here.md ├── mastering-recursion.md ├── omega-notation-the-key-to-understanding-algorithm-efficiency.md ├── optimizing-recursive-functions.md ├── practical-applications-of-recursion.md ├── understanding-big-o-notation.md └── understanding-time-space-complexity.md ├── docs ├── basic-data-structures │ ├── Method Overriding.md │ ├── Operator Overloading.md │ ├── Strings │ │ ├── Advanced-techniques.md │ │ ├── Highest freqyuency letter.md │ │ ├── Isomorphic strings.md │ │ ├── Reversing a string.md │ │ ├── What_is String.md │ │ └── kmp-algo.md │ ├── _category_.json │ ├── array │ │ ├── 2d-arrays.md │ │ ├── Kadane-Algorithm.md │ │ ├── ProudctOfArrayExceptSelf.md │ │ ├── _category_.json │ │ ├── arrays-bubblesort-dsa.md │ │ ├── arrays-dsa.md │ │ ├── arrays-insertionsort.md │ │ ├── arrays-kadanesalgorithm-dsa.md │ │ ├── arrays-selectionsort.md │ │ ├── bucket-sort.md │ │ ├── counting-sort.md │ │ ├── heap-sort.md │ │ ├── quick-sort.md │ │ └── radix-sort.md │ ├── matrix-data-structure.md │ └── pointer.md ├── content.md ├── data-structures │ ├── _category_.json │ ├── imp-of-dsa.md │ ├── roadmap-to-dsa.md │ ├── types-of-dsa.md │ └── what-is-dsa.md ├── extra │ ├── Approximation Algorithm │ │ └── Approximation.md │ ├── Banker's Algorithm │ │ └── Banker.md │ ├── Boyer Moore │ │ └── Boyer-Moore.md │ ├── Circular_array │ │ ├── Application.md │ │ └── Introduction.md │ ├── DSA-Problem-Solution │ │ ├── Add_two_number_as_LL.md │ │ ├── Clone Linked List with Random and Next Pointer.md │ │ ├── Contains_duplicate.md │ │ ├── Convert Date to Binary.md │ │ ├── Cousins in Binary Tree.md │ │ ├── Delete middle node.md │ │ ├── Delete_occurences_of_key.md │ │ ├── Find Indices of stable mountains.md │ │ ├── Loop in linked list.md │ │ ├── Merge Two Sorted Arrays.md │ │ ├── Merge_K_Sorted_Arrays.md │ │ ├── Palindrome-number.md │ │ ├── Plus-one.md │ │ ├── Segregate even and odd nodes in LinkedList.md │ │ ├── Size_of_largest_BST_in_binary_tree.md │ │ ├── Sliding Window Maximum.md │ │ ├── Symmetric Tree.md │ │ ├── flattening-a-linked-list.md │ │ ├── house-robber.md │ │ ├── longest_substring_without_repeated_characters.md │ │ ├── lowest_common_ancestor.md │ │ ├── merge_intervals.md │ │ ├── odd-even-linked-list.md │ │ ├── palindrome_linked_list.md │ │ ├── partition_equal_subset_sum.md │ │ ├── removing-stars-from-string.md │ │ ├── reverse-bits.md │ │ ├── reverse-linked-list.md │ │ ├── rotten-oranges.md │ │ └── two_sum.md │ ├── Divide and Conquer │ │ ├── Maximum-minimum.md │ │ ├── Strassen's-Matrix-Mutiplication.md │ │ └── convex-hull.md │ ├── Fenwick Tree │ │ └── FenwickTree.md │ ├── Hashing │ │ ├── CollisionHandling.md │ │ ├── OperationInsertion.md │ │ ├── OperationSearch.md │ │ ├── OperationUpdate.md │ │ ├── Tigerhashing.md │ │ ├── _category_.json │ │ ├── deletion-in-hash-table.md │ │ ├── hashsets.md │ │ ├── imp-of-hashing.md │ │ └── what-is-hashing.md │ ├── Jump Search │ │ └── Jump Search.md │ ├── KMP searching pattern │ │ ├── _category_.json │ │ └── readme.md │ ├── Number theory │ │ ├── Divisibility and Prime Numbers.md │ │ ├── GCD.md │ │ ├── LCM.md │ │ ├── Modular Arithmetic.md │ │ ├── counting-divisors.md │ │ ├── modular-exponentiation.md │ │ └── sieve-of-eratosthenes.md │ ├── Object Oriented Programming │ │ ├── 4-pillars-of-oops.md │ │ ├── ApplicationofOOPS.md │ │ ├── Polymorphism.md │ │ ├── _category_.json │ │ ├── abstraction.md │ │ ├── car.png │ │ ├── classes-and-objects.md │ │ ├── constructors-destructors.md │ │ ├── interfaces-vs-abstract-classes.md │ │ ├── intro-to-oops.md │ │ ├── intro.png │ │ ├── real-world-examples.md │ │ └── typesOfInheritance.md │ ├── Queue │ │ ├── Blocked-queue.png │ │ ├── Circular-queue.png │ │ ├── Priority-queue.png │ │ ├── Problem-Practice.md │ │ ├── Two-Stack-Queue.md │ │ ├── _category_.json │ │ ├── blocked-queue.md │ │ ├── check-palindrome-using-dequeue.md │ │ ├── circular-queue.md │ │ ├── concurrent-queue.md │ │ ├── design-circular-Dueque.md │ │ ├── design-circular-Queue.md │ │ ├── double-ended-queue.md │ │ ├── doubleendedqueue.png │ │ ├── priority-queue.md │ │ └── priority_queue_questions.md │ ├── Rabin-Karp Algorithm │ │ └── Rabin-Karp.md │ ├── Randomized Algorithm │ │ └── Randomized-Quicksort.md │ ├── Recursion-depths │ │ ├── Recursion.md │ │ ├── advanced-topics.md │ │ ├── basic-concepts.md │ │ ├── handling-depth-errors.md │ │ └── performance-consideration.md │ ├── Recursion │ │ ├── Ackerman.md │ │ ├── Count-all-subsequences-with-sum-K.md │ │ ├── GrayCodeGeneration.md │ │ ├── Josephus-Queries.md │ │ ├── Knight's_Tour_Problem.md │ │ ├── Letter-Combinations-of-a-Phone-number.md │ │ ├── N Queen 2.png │ │ ├── N Qween 1.png │ │ ├── Reversing_String.md │ │ ├── SmawkAlgorithm.md │ │ ├── Sodoko.md │ │ ├── StonePaperScissor.md │ │ ├── TowersOfHanoi.md │ │ ├── Unwinding_in_recursion.md │ │ ├── VoseAlias.md │ │ ├── WaterJug.md │ │ ├── _category_.json │ │ ├── catalannumber.md │ │ ├── fibonacci.md │ │ ├── generate-parantheses.md │ │ ├── josephus.md │ │ ├── look-and-say.md │ │ ├── n-queen.md │ │ ├── recursion.md │ │ └── ulamsequence.md │ ├── Segment-Trees │ │ ├── Dynamic Segment Trees.md │ │ ├── Practice Porblem.md │ │ ├── Segment Trees Introduction.md │ │ └── Segment-Tree-img.png │ ├── Sliding-Window │ │ ├── IntroductionToSlidingWindow.jpg │ │ ├── Problem-Practice.md │ │ ├── _category_.json │ │ ├── character-replacement.md │ │ ├── introduction-to-sliding-window.md │ │ ├── longest-repeating-character-replacement.md │ │ ├── longest-substring-with-K-different-characters.md │ │ ├── maximum-sum-subarray-size-K.md │ │ └── minimize-maximum-of-two-arrays.md │ ├── Stack │ │ ├── Balanced-Parenthesis.md │ │ ├── Balanced-parentheses-checker.md │ │ ├── Conversion.md │ │ ├── Evaluation.md │ │ ├── Introduction_to_Stack.png │ │ ├── Min-Stack.md │ │ ├── MonotonicStack.md │ │ ├── Next Greater Element (NGE).md │ │ ├── Problem-Practice.md │ │ ├── Reverse-Stack.md │ │ ├── Stack-permutation.md │ │ ├── Stock-span.md │ │ ├── String_Reversal.md │ │ ├── Trapping Rain Water Problem.md │ │ ├── _category_.json │ │ ├── introduction-to-stack.md │ │ └── stack.md │ ├── Standard Template Library │ │ ├── STL-algorithms.md │ │ ├── STL-containers.md │ │ ├── STL-iterators.md │ │ └── STL-theory.md │ ├── Strings │ │ ├── Problem-Practice.md │ │ ├── String Basics.md │ │ └── String Operation.md │ ├── Tarjan's Algorithm │ │ ├── Tarjan.md │ │ └── algorithm.png │ ├── Task Scheduling │ │ ├── Task-schedule.md │ │ └── _category_.json │ ├── Trees │ │ ├── AVL Tree.md │ │ ├── B-Trees.md │ │ ├── Expression-tree.md │ │ ├── Heap-tree.md │ │ ├── Practice Problems.md │ │ ├── Sum-tree.md │ │ ├── Trees Practice Problems.md │ │ ├── Types of Trees.md │ │ ├── balanced-tree.md │ │ ├── binary-search-tree.md │ │ ├── binary-tree.md │ │ ├── k-d tree algorithm.md │ │ └── tree-data-structure.md │ ├── Tries │ │ ├── Problem-Practice.md │ │ ├── Tries and its Implementation.md │ │ ├── tries-examples.md │ │ └── tries-theory.md │ ├── _category_.json │ ├── advance-data-structure │ │ ├── _category_.json │ │ ├── disjoint-set.md │ │ ├── fenwick-tree.md │ │ └── segment-tree.md │ ├── algorithms │ │ ├── Edmonds-Karp Algorithm │ │ │ └── edmonds-karp-algorithm.md │ │ ├── Application-of-Recursion.md │ │ ├── Application-of-linked-list.md │ │ ├── Bentley-Ottmann-Algorithm │ │ │ └── bentley-ottmann-algo.md │ │ ├── Bloom-Filter-Algorithm.md │ │ ├── Buchberger's Algorithm │ │ │ └── Buchberger's Algorithm.md │ │ ├── CNN-deep-learning-algorithm.md │ │ ├── Computer-Vision-ML-Theory.md │ │ ├── DLX algorithm │ │ │ └── DLX.md │ │ ├── Dijkstra’s Algorithm.md │ │ ├── DutchNationalFlag-algorithm │ │ │ ├── DutchNationalFlag.md │ │ │ └── _category_.json │ │ ├── Encryption algorithms │ │ │ ├── Caesar Cipher.md │ │ │ ├── advanced_encryption_standard.md │ │ │ ├── asymmetric_encryption.md │ │ │ ├── blockchain_encryption.md │ │ │ ├── elliptic_curve_cryptography.md │ │ │ ├── hashing.md │ │ │ ├── homomorphic-encryption.md │ │ │ ├── post-quantum-encryption.md │ │ │ ├── steganography-algo.md │ │ │ └── symmetric_encryption.md │ │ ├── GAN-ML-Algorithm.md │ │ ├── Gale-Shapley-Algorithm │ │ │ └── GaleShapley.md │ │ ├── Hashing-algorithm.md │ │ ├── Legendre's Algorithm │ │ │ └── legendre-algo.md │ │ ├── N-Queens-Dynamic-programming-algorithm.md │ │ ├── RNN-ML-algorithm.md │ │ ├── SMAWK Algorithm │ │ │ └── SMAWK Algorithm.md │ │ ├── Scheduling Algorithms │ │ │ ├── EarliestDeadlineFirst.md │ │ │ ├── FirstComeFirstServed.md │ │ │ ├── LeastRecentlyUsed.md │ │ │ ├── PriorityScheduling.md │ │ │ ├── RoundRobin.md │ │ │ ├── ShortestJobRemainingFirst.md │ │ │ ├── SweepLine.md │ │ │ ├── _category_.json │ │ │ ├── least-recently-used.md │ │ │ ├── multilevel-queue-scheduling.md │ │ │ └── priority-scheduling.md │ │ ├── Searching Algorithms │ │ │ ├── A-Search.md │ │ │ ├── AO-Search.md │ │ │ ├── Best-First-Search.md │ │ │ ├── BinarySearch.md │ │ │ ├── Boyer-Moore-Search.md │ │ │ ├── Breadth-First-Search-(BFS)-Algo.md │ │ │ ├── ComparisonSearch.md │ │ │ ├── Depth-First-Search-(DFS)-Algo.md │ │ │ ├── DigitalSearch.md │ │ │ ├── ExponentialSerach.md │ │ │ ├── FibbonaciSearch.md │ │ │ ├── HashingSearch.md │ │ │ ├── Interpolation-search-algorithm.md │ │ │ ├── InterpolationSearch.md │ │ │ ├── JumpSearch.md │ │ │ ├── LinearSearch.md │ │ │ ├── Meta-binary-search.md │ │ │ ├── PrioritySearch.md │ │ │ ├── Rabin-Karp-Algorithm.md │ │ │ ├── SentinelSearch.md │ │ │ ├── Sublist-Search.md │ │ │ ├── TernarySearch.md │ │ │ └── Uniform-Cost-Search.md │ │ ├── Two-Pointers │ │ │ ├── IntroductionToTwoPointers.png │ │ │ ├── Max_Distance.md │ │ │ ├── Problem-Practice.md │ │ │ ├── _category_.json │ │ │ ├── imp-of-two-pointers.md │ │ │ └── introduction-to-two-pointers.md │ │ ├── Yolo-Object-detection-ML-Algorithm.md │ │ ├── _category_.json │ │ ├── backtracking-algorithms │ │ │ ├── Bron-Kerbosch-Algorithm.md │ │ │ ├── N-QueensProblem.md │ │ │ ├── _category_.json │ │ │ ├── backtracking-questions.md │ │ │ ├── hamilton-path-cyle.md │ │ │ ├── imp-of-backtracking.md │ │ │ ├── m-coloring.md │ │ │ ├── n-queens_algorithm.md │ │ │ └── what-is-backtracking.md │ │ ├── greedy-algorithms │ │ │ ├── Fractional_Knapsack.md │ │ │ ├── Huffman-coding.md │ │ │ ├── Job-sequencing-problem.md │ │ │ ├── Prim’s-Minimum-Spanning-Tree.md │ │ │ ├── Problem-Practice.md │ │ │ ├── _category_.json │ │ │ ├── activity-selection.md │ │ │ ├── commonly-asked-greedy-questions.md │ │ │ ├── fractional-knapsack.md │ │ │ └── greedy-theory.md │ │ ├── kadane-algorithm │ │ │ ├── _category_.json │ │ │ └── kadane-algo.md │ │ ├── mathematics-algorithms │ │ │ ├── _category_.json │ │ │ ├── discrete-logarithm.md │ │ │ ├── euclidean-algorithm.md │ │ │ ├── fermat-little-theorem.md │ │ │ ├── gcd-lcm.md │ │ │ ├── imp-of-mathematics.md │ │ │ ├── modular-arithmetic.md │ │ │ ├── sieve-of-eratosthenes.md │ │ │ ├── sweep-line-algorithm.md │ │ │ └── what-is-mathematical-algorithms.md │ │ ├── memoisation-algorithms │ │ │ ├── _category_.json │ │ │ ├── imp-of-memoisation.md │ │ │ └── what-is-memoisation.md │ │ ├── modular-exponentiation-algorithm.md │ │ ├── moores-voting-algorithm │ │ │ └── moore-voting-algo.md │ │ ├── recursive-algorithms │ │ │ ├── DirectRecursion.md │ │ │ ├── IndirectRecursion.md │ │ │ ├── _category_.json │ │ │ ├── mutual-recursion.md │ │ │ ├── non-tail-recursion.md │ │ │ ├── tail-recursion.md │ │ │ └── tree-recursion.md │ │ ├── sorting-algorithms │ │ │ ├── BitonicSort.md │ │ │ ├── BogoSort.md │ │ │ ├── BubbleSort.md │ │ │ ├── BucketSort.md │ │ │ ├── CocktailShakerSort.md │ │ │ ├── CombSort.md │ │ │ ├── CountingSort.md │ │ │ ├── CycleSort.md │ │ │ ├── Dutch-flag-algo.md │ │ │ ├── GnomeSort.md │ │ │ ├── HeapSort.md │ │ │ ├── InsertionSort.md │ │ │ ├── JumpSort.md │ │ │ ├── MergeSort.md │ │ │ ├── Odd-Even-Sort.md │ │ │ ├── OddEvenSort.md │ │ │ ├── Pancake-sorting-algorithm.md │ │ │ ├── Pigeonhole.md │ │ │ ├── QuickSort.md │ │ │ ├── RadixSort.md │ │ │ ├── SelectionSort.md │ │ │ ├── ShellSort.md │ │ │ ├── StoogeSort.md │ │ │ ├── TimSort.md │ │ │ ├── Topological-sorting-algorithm.md │ │ │ ├── TreeSort.md │ │ │ ├── _category_.json │ │ │ ├── odd-even-sorting.md │ │ │ ├── parity-partition-sort.md │ │ │ └── strand-sort.md │ │ └── string-algorithms │ │ │ ├── Naive-String-Matching-Algorithm.md │ │ │ ├── Naive-search.md │ │ │ ├── Suffix-Tree-Algorithm.md │ │ │ ├── Z-Algorithm.md │ │ │ ├── _category_.json │ │ │ ├── aho-corasick-algorithm.md │ │ │ ├── apostolico-giancarlo-algorithm.md │ │ │ ├── berry-ravindran-algorithm.md │ │ │ ├── bitap-algorithm.md │ │ │ ├── bndm-algorithm.md │ │ │ ├── colussi-algorithm.md │ │ │ ├── commentz-walter-algorithm.md │ │ │ ├── crochemores-algorithm.md │ │ │ ├── finite-state-automation-algorithm.md │ │ │ ├── kmp-algorithm.md │ │ │ ├── kmp-algorithms.md │ │ │ ├── lcs-algorithm.md │ │ │ ├── levenshtein-distance-algorithm.md │ │ │ ├── manacher-algorithm.md │ │ │ ├── needleman-wunsch-algorithm.md │ │ │ ├── not-so-naive-algorithm.md │ │ │ ├── optimal-mismatch-algorithm.md │ │ │ ├── quick-search-algorithm.md │ │ │ ├── rabin-karp-algorithms.md │ │ │ ├── reverse-factor-algorithm.md │ │ │ ├── shift-or-algorithm.md │ │ │ ├── simon-algorithm.md │ │ │ ├── smith-waterman-algorithm.md │ │ │ ├── suffix-array-algorithm.md │ │ │ ├── sunday-algorithm.md │ │ │ ├── turbo-boyer-moore-algorithm.md │ │ │ ├── two-way-string-matching-algorithm.md │ │ │ ├── ukkonens-algorithm.md │ │ │ └── zhu-takaoka-algorithm.md │ ├── b-tree │ │ ├── B-Tree-1.md │ │ ├── B-Tree-2.md │ │ ├── B-Tree-3.md │ │ └── image │ │ │ ├── BTree2Ins.png │ │ │ ├── BTreeIns3.png │ │ │ ├── BTreeIns4.png │ │ │ ├── BTreeIns6.png │ │ │ ├── BTreeSplit-1024x321.jpg │ │ │ ├── Btree1.png │ │ │ ├── delete.png │ │ │ ├── delete2.png │ │ │ ├── output253.png │ │ │ ├── output254.png │ │ │ ├── output255.png │ │ │ └── output256.png │ ├── backtracking algorithms │ │ └── Tiling-problem.md │ ├── balancedBinTree │ │ ├── balancedBinTree.md │ │ ├── balancedBinTreejava.md │ │ └── balancedBinTreejavaScript.md │ ├── basic-dsa │ │ ├── Method Overriding.md │ │ ├── Operator Overloading.md │ │ ├── Strings │ │ │ ├── Advanced-techniques.md │ │ │ ├── Highest freqyuency letter.md │ │ │ ├── Isomorphic strings.md │ │ │ ├── Reversing a string.md │ │ │ ├── What_is String.md │ │ │ └── kmp-algo.md │ │ ├── _category_.json │ │ ├── array │ │ │ ├── 2d-arrays.md │ │ │ ├── Kadane-Algorithm.md │ │ │ ├── ProudctOfArrayExceptSelf.md │ │ │ ├── _category_.json │ │ │ ├── arrays-bubblesort-dsa.md │ │ │ ├── arrays-dsa.md │ │ │ ├── arrays-insertionsort.md │ │ │ ├── arrays-kadanesalgorithm-dsa.md │ │ │ ├── arrays-selectionsort.md │ │ │ ├── bucket-sort.md │ │ │ ├── counting-sort.md │ │ │ ├── heap-sort.md │ │ │ ├── quick-sort.md │ │ │ └── radix-sort.md │ │ ├── matrix-data-structure.md │ │ └── pointer.md │ ├── binary-search-tree │ │ ├── Binary search tree.md │ │ ├── Post_order_traversal.md │ │ ├── Problem-Practice.md │ │ ├── _category_.json │ │ ├── avl-tree.md │ │ ├── delete-BST.md │ │ ├── inorder-predecessor-BST.md │ │ ├── inorder-successor-BST.md │ │ ├── insert-BST.md │ │ ├── red-black-trees.md │ │ └── search-BST.md │ ├── binary-search │ │ ├── Exponential-Search.md │ │ ├── Iterative_binary_search.md │ │ ├── Painter_Partition_problem.md │ │ ├── Problem-Practice.md │ │ ├── _category_.json │ │ ├── binary-search.md │ │ ├── binary-search_rotated-sorted-array.md │ │ ├── binary.md │ │ ├── binary_search_questions.md │ │ ├── matrix-binary-dsa.md │ │ └── recursive_binary_search.md │ ├── binary-trees │ │ ├── _category_.json │ │ ├── basic-operations.md │ │ ├── binary-tree.md │ │ ├── expression-tree.md │ │ ├── maximum-depth.md │ │ ├── merkle-tree.md │ │ ├── minimum-depth.md │ │ ├── practice-problems.md │ │ └── splay-trees.md │ ├── bit-manipulation │ │ ├── _category_.json │ │ ├── bit-manipulation-technique.md │ │ ├── bitmanipulation-practice-problem.md │ │ ├── brain-kernighan-algo.md │ │ ├── clear-ith-Bit.md │ │ ├── count-set-bits.md │ │ ├── power-of-two.md │ │ └── toggle-bit-at-position.md │ ├── challenges solutions │ │ ├── Challenge4.md │ │ ├── _category_.json │ │ ├── challenge1.md │ │ ├── challenge2.md │ │ └── challenge3.md │ ├── combinatorics │ │ ├── Practice-problems.md │ │ ├── _category_.json │ │ ├── combinatorics-examples.md │ │ └── combinatorics-theory.md │ ├── complexity │ │ ├── _category_.json │ │ ├── how-to-calculate-complexity.md │ │ ├── image-1.png │ │ ├── image.png │ │ ├── space-complexity.md │ │ ├── time-complexity.md │ │ └── time-space-complexity.md │ ├── dsa │ │ └── _category_.json │ ├── dynamic-programming │ │ ├── Beautiful-Subgrids.md │ │ ├── Matrix-chain-multiplication.md │ │ ├── Multistage-graph.md │ │ ├── Two-City-Scheduling-3D-DP.md │ │ ├── _category_.json │ │ ├── approaches.md │ │ ├── dynamic-programming-optimizations.md │ │ ├── fence-painting.md │ │ ├── house-robber.md │ │ ├── how-to-identify.md │ │ ├── longest-zig-zag-subsequence.md │ │ ├── longest_common_subsequence.md │ │ ├── minimum_flips_to_zero_matrix.md │ │ ├── palindrome_partitioning_IV.md │ │ ├── practice-problems-different-patterns.md │ │ └── trapped-rainwater.md │ ├── fundamentals │ │ ├── Conditional Statement.md │ │ ├── Functions │ │ │ ├── Function Call.md │ │ │ ├── Function Closures.md │ │ │ ├── Function Composition.md │ │ │ ├── Function Currying.md │ │ │ ├── Function Declaration.md │ │ │ ├── Function Memoization.md │ │ │ ├── Function Overloading.md │ │ │ ├── Function Parameters.md │ │ │ ├── Function Recursion.md │ │ │ ├── Function Return.md │ │ │ └── Function Scope.md │ │ └── Loops.md │ ├── game-Theory │ │ ├── gameTheory.md │ │ └── gameTheoryExamples.md │ ├── graphs │ │ ├── Adjacency-List.md │ │ ├── Adjacency-Matrix.md │ │ ├── Disjoint Set Union.md │ │ ├── Johnson's-algo.md │ │ ├── Longest-path-in-DAG.md │ │ ├── Page-Rank-Algorithm.md │ │ ├── Practice Problems.md │ │ ├── _category_.json │ │ ├── ant-colony-optimization-tsp.md │ │ ├── bfs.md │ │ ├── bipartite-graph.md │ │ ├── dfs.md │ │ ├── dfs_java.md │ │ ├── dijkstra-algo.md │ │ ├── eulerian-graphs.md │ │ ├── flood-fill.md │ │ ├── floyd-algorithm.md │ │ ├── graph-cloning.md │ │ ├── graph-coloring.md │ │ ├── graph-reversal.md │ │ ├── hopcroft-karp-algorithm.md │ │ ├── kahn-algo.md │ │ ├── kosaraju-algorithm.md │ │ ├── kruskal-algorithm.md │ │ ├── minimum-cost-spanning-tree.md │ │ ├── practice-problems.md │ │ ├── prims-algorithm.md │ │ ├── shortest-path-algorithms │ │ │ ├── A-star-algorithm.md │ │ │ ├── Prims-algorithm.md │ │ │ ├── _category_.json │ │ │ ├── bell-man-ford-algorithm.md │ │ │ ├── dijkstra-algorithm.md │ │ │ └── floyd-warshall-algorithm.md │ │ ├── tarjans-algo.md │ │ └── warshall-algo.md │ ├── greedy-algorithms │ │ ├── Graph-Coloring.md │ │ ├── fractional-knapsack-algorithm.md │ │ ├── job-scheduling.md │ │ ├── kruskals-algorithm.md │ │ └── prims-algorithm.md │ ├── hash │ │ ├── Practice Problems.md │ │ ├── _category_.json │ │ └── hash-tables.md │ ├── heap │ │ ├── Add-Merge-k-sorted-lists.md │ │ ├── Kth-largest-using-min_heap.md │ │ ├── Median-of-a-stream.md │ │ ├── Problem-Practice.md │ │ ├── _category_.json │ │ ├── heap-basics.md │ │ ├── heap-operations.md │ │ ├── kth-largest.md │ │ ├── kth-smallest.md │ │ ├── time-complexity.md │ │ └── top-k-frequent-elements.md │ ├── knapsack-disaster-relief │ │ └── knapsack-disaster-relief.md │ ├── linked-list │ │ ├── CircularDoubly.png │ │ ├── CircularLinkedList.png │ │ ├── Doubly-linked-list-C.md │ │ ├── DoublyLL.png │ │ ├── Hare-Tortoise.md │ │ ├── Intersection_Linked_list_python.md │ │ ├── LinkedList.png │ │ ├── Polynomial-Addition.md │ │ ├── Polynomial_multiplication.md │ │ ├── Practice-Problems.md │ │ ├── _category_.json │ │ ├── circular-doubly-linked-list.md │ │ ├── doubly-linked-list.md │ │ ├── floyds-cycle-detection.md │ │ ├── gircular-linked-list.md │ │ ├── intersection-linked-lists.md │ │ ├── introduction-to-linked-list.md │ │ ├── linked-list-approaches.md │ │ ├── max-twin-sum-of-linked-list.md │ │ ├── merge-two-sorted-list.md │ │ ├── next-greater-node-in-linked-list.md │ │ ├── polynomial-representation.md │ │ ├── range-sum-of-linked-list.md │ │ ├── remove-duplicates-from-sorted-list.md │ │ └── swapping-node-in-a-linked-list-at-kth-node.md │ ├── machine-learning │ │ ├── AdaBoost.md │ │ ├── Autoencoders.md │ │ ├── BeamSearch.md │ │ ├── Catboost.md │ │ ├── Convolutional_Neural_Network.md │ │ ├── DBSCAN_Clustering_Algorithm.md │ │ ├── Extra_Trees.md │ │ ├── GBM.md │ │ ├── Gaussian_Mixture_Model.md │ │ ├── Generative_Adversarial_Networks.md │ │ ├── HBOS.md │ │ ├── Hidden_Markov_Model.md │ │ ├── HierarchialClustering.md │ │ ├── Independent Component Analysis.md │ │ ├── K-Means_clustering.md │ │ ├── K-NearestNeighbours.md │ │ ├── LinearRegression.md │ │ ├── LogisticRegression.md │ │ ├── Long_Short_Term_Memory.md │ │ ├── PC_Visualizations.md │ │ ├── Recurrent_Neural_Network.md │ │ ├── Reinforcement_Learning.md │ │ ├── RidgeRegression.md │ │ ├── SDG.md │ │ ├── SVM.md │ │ ├── Silhoutte.md │ │ ├── Singular_Value_Decomposition_Algorithm.md │ │ ├── Statistical_Anomaly_Detection.md │ │ ├── Time_Series_Forecasting_Algo.md │ │ ├── XGBoost.md │ │ ├── decisionTree.md │ │ ├── deep-q-networks.md │ │ ├── hierarchical-clustering-visualizations.md │ │ ├── lasso_regression.md │ │ ├── naive-bayes.md │ │ ├── neuralNetworks.md │ │ ├── policy-gradient-visualization.md │ │ ├── principal-component-analysis.md │ │ ├── qLearning.md │ │ ├── random-forest.md │ │ ├── regression_algorithm.md │ │ ├── supervised_learning_algo.md │ │ ├── support-vector-machine.md │ │ ├── t-SNE_Dimensionality_Reduction.md │ │ ├── tsne-visualization.md │ │ └── unsupervised_learning_algo.md │ └── sortings │ │ ├── Sortings.md │ │ └── shell-sort .md ├── index.md ├── languages │ ├── C │ │ ├── c-0.md │ │ ├── c-1.md │ │ ├── c-2.md │ │ ├── c-3.md │ │ ├── c-4.md │ │ ├── c-5.md │ │ └── c-6.md │ ├── SQL │ │ ├── sql-1.md │ │ ├── sql-10.md │ │ ├── sql-11.md │ │ ├── sql-12.md │ │ ├── sql-13.md │ │ ├── sql-14.md │ │ ├── sql-15.md │ │ ├── sql-16.md │ │ ├── sql-17.md │ │ ├── sql-18.md │ │ ├── sql-19.md │ │ ├── sql-2.md │ │ ├── sql-20.md │ │ ├── sql-21.md │ │ ├── sql-22.md │ │ ├── sql-23.md │ │ ├── sql-24.md │ │ ├── sql-25.md │ │ ├── sql-26.md │ │ ├── sql-27.md │ │ ├── sql-28.md │ │ ├── sql-29.md │ │ ├── sql-3.md │ │ ├── sql-30.md │ │ ├── sql-31.md │ │ ├── sql-32.md │ │ ├── sql-33.md │ │ ├── sql-4.md │ │ ├── sql-5.md │ │ ├── sql-6.md │ │ ├── sql-7.md │ │ ├── sql-8.md │ │ └── sql-9.md │ ├── _category_.json │ ├── cpp │ │ ├── _category_.json │ │ ├── cp-0.md │ │ ├── cp-1.md │ │ ├── cp-10.md │ │ ├── cp-11.md │ │ ├── cp-12.md │ │ ├── cp-13.md │ │ ├── cp-2.md │ │ ├── cp-3.md │ │ ├── cp-4.md │ │ ├── cp-5.md │ │ ├── cp-6.md │ │ ├── cp-7.md │ │ ├── cp-8.md │ │ └── cp-9.md │ ├── csharp │ │ ├── _category_.json │ │ ├── csharp-0.md │ │ ├── csharp-1.md │ │ ├── csharp-2.md │ │ ├── csharp-3.md │ │ ├── csharp-4.md │ │ ├── csharp-5.md │ │ ├── csharp-6.md │ │ ├── csharp-7.md │ │ ├── csharp-8.md │ │ └── csharp-9.md │ ├── java │ │ ├── _category_.json │ │ ├── ex1.md │ │ ├── ex2.md │ │ ├── ex4.md │ │ ├── java-1.md │ │ ├── java-10.md │ │ ├── java-11.md │ │ ├── java-12.md │ │ ├── java-2.md │ │ ├── java-3.md │ │ ├── java-4.md │ │ ├── java-5-1.md │ │ ├── java-6.md │ │ ├── java-7.md │ │ ├── java-8.md │ │ └── java-9.md │ ├── javascript │ │ ├── _category_.json │ │ ├── js-0.md │ │ ├── js-1.md │ │ ├── js-10.md │ │ ├── js-11.md │ │ ├── js-12.md │ │ ├── js-13.md │ │ ├── js-14.md │ │ ├── js-15.md │ │ ├── js-16.md │ │ ├── js-17.md │ │ ├── js-2.md │ │ ├── js-3.md │ │ ├── js-4.md │ │ ├── js-5.md │ │ ├── js-6.md │ │ ├── js-7.md │ │ ├── js-8.md │ │ └── js-9.md │ └── python │ │ ├── _category_.json │ │ ├── py-1.md │ │ ├── py-10.md │ │ ├── py-11.md │ │ ├── py-12.md │ │ ├── py-13.md │ │ ├── py-14.md │ │ ├── py-15.md │ │ ├── py-16.md │ │ ├── py-17.md │ │ ├── py-18.md │ │ ├── py-2.md │ │ ├── py-3.md │ │ ├── py-4.md │ │ ├── py-5.md │ │ ├── py-6.md │ │ ├── py-7.md │ │ ├── py-8.md │ │ └── py-9.md └── programming-fundamentals │ ├── _category_.json │ ├── control-structures │ ├── _category_.json │ ├── break.md │ ├── continue.md │ ├── do-while-loop.md │ ├── finally.md │ ├── for-loop.md │ ├── if-else.md │ ├── return.md │ ├── switch.md │ ├── throw.md │ ├── try-catch.md │ └── while-loop.md │ ├── functions │ ├── _category_.json │ ├── function-call.md │ ├── function-closures.md │ ├── function-composition.md │ ├── function-currying.md │ ├── function-declaration.md │ ├── function-memoization.md │ ├── function-overloading.md │ ├── function-parameters.md │ ├── function-recursion.md │ ├── function-return.md │ └── function-scope.md │ ├── language-syntax │ ├── _category_.json │ ├── arrays.md │ ├── classes.md │ ├── conditionals.md │ ├── functions.md │ ├── inheritance.md │ ├── interfaces.md │ ├── loops.md │ ├── objects.md │ ├── operators.md │ ├── polymorphism.md │ ├── strings.md │ └── variables.md │ ├── oop-basics │ ├── _category_.json │ ├── abstract-classes.md │ ├── abstraction.md │ ├── classes.md │ ├── composition.md │ ├── delegation.md │ ├── encapsulation.md │ ├── inheritance.md │ ├── interfaces.md │ ├── mixins.md │ ├── objects.md │ └── polymorphism.md │ └── pseudo-code │ ├── Introduction.md │ ├── arrays.md │ ├── classes.md │ ├── conditionals.md │ ├── functions.md │ ├── inheritance.md │ ├── loops.md │ ├── objects.md │ ├── operators.md │ ├── polymorphism.md │ ├── strings.md │ └── variables.md ├── docusaurus.config.js ├── dsa-interview-sidebars.js ├── dsa-interview └── index.md ├── festhack.jpg ├── girlscript.jpg ├── learn.md ├── package-lock.json ├── package.json ├── plugins └── my-plugin │ └── index.js ├── postman.png ├── renovate.json ├── sidebars.js ├── src ├── components │ ├── AdsComponent │ │ ├── Ads.tsx │ │ ├── index.tsx │ │ └── style.css │ ├── ChallengeCard.tsx │ ├── DSA │ │ ├── DP │ │ │ └── Parsing A Boolean Expression.md │ │ ├── arrays │ │ │ ├── ArrayVisualizations │ │ │ │ └── index.tsx │ │ │ ├── BubbleSortVisualization │ │ │ │ ├── BubbleSortVisualization.css │ │ │ │ └── index.tsx │ │ │ ├── HeapSortVisualization │ │ │ │ ├── index.tsx │ │ │ │ └── style.css │ │ │ ├── InsertionSortVisualization │ │ │ │ ├── index.tsx │ │ │ │ └── style.css │ │ │ ├── MergeSortVisualization │ │ │ │ ├── index.tsx │ │ │ │ └── style.css │ │ │ ├── QuickSortVisualization │ │ │ │ ├── index.tsx │ │ │ │ └── style.css │ │ │ ├── SelectionSortVisualization │ │ │ │ ├── SelectionSortVisualization.css │ │ │ │ └── index.tsx │ │ │ └── ShellSortVisualisation │ │ │ │ ├── Shellsort.css │ │ │ │ └── index.tsx │ │ └── graphs │ │ │ ├── DijkstraVisualizations │ │ │ └── index.tsx │ │ │ └── FloydWarshallVisualizations │ │ │ └── index.tsx │ ├── GiscusComponent │ │ └── index.tsx │ ├── Header.tsx │ ├── Highlight │ │ └── index.js │ ├── Homepage │ │ ├── CallToActionSection.tsx │ │ ├── ContributeSection.tsx │ │ ├── FeaturesSection.tsx │ │ ├── GetInvolvedSection.tsx │ │ ├── HeroSection.tsx │ │ ├── HowItWorksSection.tsx │ │ ├── PopularAlgorithmsSection.tsx │ │ ├── TechnologiesSection.tsx │ │ ├── UserTestimonialsSection.tsx │ │ └── index.tsx │ ├── QuizCard.tsx │ ├── Scroller │ │ ├── BottomToTop │ │ │ └── BottomToTop.tsx │ │ └── TopToBottom │ │ │ └── TopToBottom.tsx │ ├── Visualizing │ │ └── index.tsx │ └── chatbot.jsx ├── css │ ├── BottomToTop.module.css │ ├── TopToBottom.module.css │ ├── custom.css │ └── visualiezer.css ├── data │ ├── challengeData.ts │ ├── quizData.ts │ ├── testimonialsData.ts │ └── topics.ts ├── pages │ ├── License.md │ ├── about │ │ └── index.tsx │ ├── blogs │ │ └── index.tsx │ ├── challenges │ │ ├── challenge1.tsx │ │ ├── challenge2.tsx │ │ ├── challenge3.tsx │ │ └── index.tsx │ ├── community │ │ └── index.tsx │ ├── contact │ │ └── index.tsx │ ├── contributors │ │ └── index.tsx │ ├── dsa-roadmap │ │ └── index.tsx │ ├── faq │ │ └── index.tsx │ ├── index.js │ ├── leaderboard │ │ └── index.tsx │ ├── markdown-page.md │ ├── practice │ │ └── index.tsx │ ├── quiz-solutions │ │ ├── array.md │ │ ├── b-trees.md │ │ ├── binary-search-trees.md │ │ ├── binary-trees.md │ │ ├── index.tsx │ │ ├── queues.md │ │ ├── red-black-trees.md │ │ └── stack.md │ ├── quizes │ │ ├── arrays.tsx │ │ ├── b-tree.tsx │ │ ├── binary-search-tree.tsx │ │ ├── binary-tree.tsx │ │ ├── index.tsx │ │ ├── queue.tsx │ │ ├── queues.tsx │ │ ├── red-black-tree.tsx │ │ └── stack.tsx │ ├── resources │ │ └── index.tsx │ ├── roadmap │ │ └── index.tsx │ └── terms │ │ └── index.tsx └── theme │ ├── Admonition │ ├── Icon │ │ └── Danger.js │ └── Layout │ │ └── index.js │ ├── CodeBlock │ └── Line │ │ ├── index.js │ │ └── styles.module.css │ ├── Footer │ └── index.tsx │ ├── MDXComponents.js │ ├── Mermaid │ └── index.js │ ├── ReactLiveScope │ ├── components.js │ └── index.js │ └── Root.js ├── static ├── .nojekyll ├── ads.txt ├── banner │ ├── banner-1.jpg │ ├── banner-1.png │ ├── banner-10.jpg │ ├── banner-13.jpg │ ├── banner-2.jpg │ ├── banner-3.jpg │ └── banner-4.jpg ├── images │ ├── avatar-2.jpg │ ├── avatar1.jpg │ ├── avatar2.jpg │ ├── avatar3.jpg │ ├── docusaurus.svg │ ├── github.svg │ ├── jsx.svg │ ├── mission.jpg │ ├── node-js.svg │ ├── tailwindcss.svg │ ├── team-member-1.jpg │ ├── team-member-2.jpg │ ├── team-member-3.jpg │ ├── team-member-4.jpg │ ├── team-member-5.jpg │ └── tsx.svg ├── img │ ├── docusaurus-social-card.jpg │ ├── docusaurus.png │ ├── favicon.ico │ ├── logo.svg │ ├── undraw_docusaurus_mountain.svg │ ├── undraw_docusaurus_react.svg │ └── undraw_docusaurus_tree.svg ├── landing │ ├── calendar.svg │ ├── chat.svg │ ├── customer.svg │ ├── grid-dark.svg │ └── grid-light.svg └── logo │ ├── algo-1.png │ ├── algo-3.png │ ├── algo-banner.png │ ├── algo.png │ ├── dsa.png │ ├── ft-copy.png │ ├── logo.png │ └── neural.png └── tailwind.config.js /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @ajay-dhangar -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: "🚀 Join the Algo Community" 3 | url: "https://forms.gle/8EpYfRgVmrDxXAio6" 4 | about: > 5 | ✨ If you would like to join the Algo community, please fill out the form to request an invitation. 6 | Provide details about your skills and motivation for joining. We will review your request and 7 | send an invitation if approved. 8 | - name: "👥 Join the Algo Community on LinkedIn" 9 | url: "https://www.linkedin.com/groups/14536479/" 10 | about: "🌐 Join our LinkedIn group to connect with fellow developers, discuss data structures and algorithms, and grow your skills together." 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.yml: -------------------------------------------------------------------------------- 1 | name: 📚 Documentation 2 | description: Report an issue related to documentation 3 | labels: [documentation, 'docs: algo contributors'] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | This template is strictly used for documentation requests, including: 9 | 10 | - Documenting new topics or features; 11 | - Elaborating on a specific subject in the DSA content; 12 | - Updating or fixing existing content; 13 | - Enhancing code examples or explanations; 14 | - Anything else that involves documentation but does not change the codebase. 15 | 16 | Before submitting an issue, please ensure: 17 | 18 | - You have checked the existing documentation to confirm the information is missing or needs updating. 19 | - For issues caused by incorrect behavior in code, use the "bug" template instead. 20 | 21 | If you are confident that your documentation request meets these criteria, you may also submit a pull request directly. 22 | 23 | - type: checkboxes 24 | attributes: 25 | label: Have you read the Contributing Guidelines on issues? 26 | options: 27 | - label: I have read the [Contributing Guidelines on issues](https://github.com/ajay-dhangar/algo/blob/main/CONTRIBUTING.md). 28 | required: true 29 | 30 | - type: textarea 31 | attributes: 32 | label: Description 33 | description: A clear and concise description of what the documentation issue is. 34 | validations: 35 | required: true 36 | 37 | - type: checkboxes 38 | attributes: 39 | label: Self-service 40 | description: | 41 | If you're willing to work on this documentation request, please check the box below. This indicates to the maintainers that you're already working on it. 42 | If you check the box, please send a pull request within 7 days to avoid reassignment. 43 | options: 44 | - label: I'd be willing to address this documentation request myself. 45 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/idea.yml: -------------------------------------------------------------------------------- 1 | name: "💡 Idea" 2 | description: "Submit an idea for Algo." 3 | title: "[Idea]: " 4 | labels: ["idea", "enhancement"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | This template is for submitting new ideas or enhancements for Algo. 10 | 11 | - type: input 12 | id: idea_title 13 | attributes: 14 | label: "Idea Title" 15 | description: "Provide a short title for your idea." 16 | placeholder: "E.g., Add a new sorting algorithm visualization" 17 | validations: 18 | required: true 19 | 20 | - type: textarea 21 | id: idea_description 22 | attributes: 23 | label: "Idea Description" 24 | description: "Describe your idea in detail. Explain the problem it solves or the value it adds." 25 | placeholder: "Provide a detailed description of your idea..." 26 | validations: 27 | required: true 28 | 29 | - type: checkboxes 30 | id: benefits 31 | attributes: 32 | label: "Potential Benefits" 33 | description: "What benefits does your idea bring?" 34 | options: 35 | - label: "Improves user experience" 36 | - label: "Enhances learning" 37 | - label: "Adds a new feature" 38 | - label: "Improves code quality" 39 | - label: "Other" 40 | 41 | - type: textarea 42 | id: implementation_suggestions 43 | attributes: 44 | label: "Implementation Suggestions (Optional)" 45 | description: "If you have any suggestions on how to implement your idea, share them here." 46 | placeholder: "Provide your thoughts on implementation..." 47 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## 📥 Pull Request 2 | 3 | ### Description 4 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. 5 | 6 | Fixes # (issue number) 7 | 8 | ### Type of change 9 | 10 | - [ ] Bug fix (non-breaking change which fixes an issue) 11 | - [ ] New feature (non-breaking change which adds functionality) 12 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 13 | - [ ] Documentation update 14 | 15 | ### Checklist: 16 | 17 | - [ ] My code follows the style guidelines of this project 18 | - [ ] I have performed a self-review of my code 19 | - [ ] I have commented my code, particularly in hard-to-understand areas 20 | - [ ] I have added tests that prove my fix is effective or that my feature works 21 | - [ ] New and existing unit tests pass locally with my changes 22 | - [ ] Any dependent changes have been merged and published in downstream modules 23 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: 'v$NEXT_PATCH_VERSION' 2 | tag-template: 'v$NEXT_PATCH_VERSION' 3 | categories: 4 | - title: '🚀 New Features' 5 | labels: 6 | - 'feature' 7 | - title: '🐛 Bug Fixes' 8 | labels: 9 | - 'bug' 10 | - title: '📖 Documentation' 11 | labels: 12 | - 'documentation' 13 | - title: '🛠 Maintenance' 14 | labels: 15 | - 'chore' 16 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 17 | template: | 18 | ## What's Changed 19 | $CHANGES 20 | -------------------------------------------------------------------------------- /.github/workflows/autolabel.yml: -------------------------------------------------------------------------------- 1 | name: Auto Label Issue 2 | 3 | on: 4 | issues: 5 | types: [opened, reopened, edited] 6 | 7 | jobs: 8 | label_issue: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | issues: write 12 | steps: 13 | - name: Label Issue 14 | uses: actions/github-script@v6 15 | with: 16 | github-token: ${{secrets.GITHUB_TOKEN}} 17 | script: | 18 | const issue = context.payload.issue; 19 | const issueBody = issue.body ? issue.body.toLowerCase() : ''; 20 | const issueTitle = issue.title.toLowerCase(); 21 | 22 | // Add gssoc-ext and hacktoberfest labels to all issues 23 | await github.rest.issues.addLabels({ 24 | owner: context.repo.owner, 25 | repo: context.repo.repo, 26 | issue_number: issue.number, 27 | // labels: ['gssoc-ext', 'hacktoberfest-accepted', 'level1'] 28 | labels: ['in-review'] 29 | }); 30 | 31 | const addLabel = async (label) => { 32 | await github.rest.issues.addLabels({ 33 | owner: context.repo.owner, 34 | repo: context.repo.repo, 35 | issue_number: issue.number, 36 | labels: [label] 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. 4 | # 5 | # Source repository: https://github.com/actions/dependency-review-action 6 | # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement 7 | name: 'Dependency Review' 8 | on: [pull_request] 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | dependency-review: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: 'Checkout Repository' 18 | uses: actions/checkout@v4 19 | - name: 'Dependency Review' 20 | uses: actions/dependency-review-action@v4 21 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to GitHub Pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | # Review GitHub Actions docs if you want to further define triggers, paths, etc. 8 | # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on 9 | 10 | jobs: 11 | build: 12 | name: Build Algo 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v4 16 | with: 17 | fetch-depth: 0 18 | - uses: actions/setup-node@v4 19 | with: 20 | node-version: 18 21 | cache: npm 22 | 23 | - name: Install dependencies 24 | run: npm ci 25 | 26 | - name: Build website 27 | run: npm run build 28 | 29 | - name: Upload Build Artifact 30 | uses: actions/upload-pages-artifact@v3 31 | with: 32 | path: build 33 | 34 | deploy: 35 | name: Deploy to GitHub Pages 36 | needs: build 37 | 38 | # Grant GITHUB_TOKEN the permissions required to make a Pages deployment 39 | permissions: 40 | pages: write # to deploy to Pages 41 | id-token: write # to verify the deployment originates from an appropriate source 42 | 43 | # Deploy to the github-pages environment 44 | environment: 45 | name: github-pages 46 | url: ${{ steps.deployment.outputs.page_url }} 47 | 48 | runs-on: ubuntu-latest 49 | steps: 50 | - name: Deploy to GitHub Pages 51 | id: deployment 52 | uses: actions/deploy-pages@v4 53 | -------------------------------------------------------------------------------- /.github/workflows/issue_close_open.yml: -------------------------------------------------------------------------------- 1 | name: Issue Auto Comment 2 | 3 | # Created by @smog-root 4 | 5 | on: 6 | issues: 7 | types: [opened, closed] 8 | 9 | jobs: 10 | comment: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Add a comment when an issue is opened 14 | if: github.event.action == 'opened' 15 | uses: actions-ecosystem/action-create-comment@v1 16 | with: 17 | github_token: ${{ secrets.GITHUB_TOKEN }} 18 | issue_number: ${{ github.event.issue.number }} 19 | body: "👋 Thanks for opening this issue! We appreciate your contribution. Please make sure you’ve provided all the necessary details and screenshots, and don't forget to follow our Guidelines and Code of Conduct. Happy coding! 🚀 20 | " 21 | 22 | - name: Add a comment when an issue is closed 23 | if: github.event.action == 'closed' 24 | uses: actions-ecosystem/action-create-comment@v1 25 | with: 26 | github_token: ${{ secrets.GITHUB_TOKEN }} 27 | issue_number: ${{ github.event.issue.number }} 28 | body: " ✅ This issue has been successfully closed. Thank you for your contribution and helping us improve the project! If you have any more ideas or run into other issues, feel free to open a new one. Happy coding! 🚀" -------------------------------------------------------------------------------- /.github/workflows/lighthouserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "ci": { 3 | "collect": { 4 | "startServerCommand": "npm run serve", 5 | "startServerReadyPattern": "Serving", 6 | "startServerReadyTimeout": 10000, 7 | "numberOfRuns": 1, 8 | "settings": { 9 | "skipAudits": [ 10 | "robots-txt", 11 | "canonical", 12 | "tap-targets", 13 | "is-crawlable", 14 | "works-offline", 15 | "offline-start-url" 16 | ] 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /.github/workflows/pr_merge.yaml: -------------------------------------------------------------------------------- 1 | name: Merge Thank You 2 | 3 | # Created by @smog-root 4 | 5 | on: 6 | pull_request_target: 7 | types: [closed] # Trigger when a PR is closed 8 | 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | 13 | jobs: 14 | post_merge_message: 15 | if: github.event.pull_request.merged == true # Only run if the PR was merged 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - name: Post thank you message 20 | uses: actions/github-script@v7 21 | with: 22 | github-token: ${{ secrets.GITHUB_TOKEN }} # Ensure token is used 23 | script: | 24 | const prNumber = context.payload.pull_request.number; 25 | const owner = context.repo.owner; 26 | const repo = context.repo.repo; 27 | 28 | // Post a thank you message upon PR merge 29 | await github.rest.issues.createComment({ 30 | owner: owner, 31 | repo: repo, 32 | issue_number: prNumber, 33 | body: `🎉🎉 Thank you for your contribution! Your PR #${prNumber} has been merged! 🎉🎉` 34 | }); -------------------------------------------------------------------------------- /.github/workflows/pr_raise.yml: -------------------------------------------------------------------------------- 1 | name: Auto Comment on PR 2 | 3 | # Created by @smog-root 4 | 5 | on: 6 | pull_request_target: 7 | types: [opened] 8 | 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | 13 | jobs: 14 | comment: 15 | runs-on: ubuntu-latest 16 | permissions: 17 | pull-requests: write 18 | steps: 19 | - name: Add Comment to Pull Request 20 | run: | 21 | COMMENT=$(cat < 11 | 12 | In this blog, we'll compare: 13 | 14 | - **Performance**: How recursion and iteration differ in execution time and space. 15 | - **Readability**: The clarity of code in recursive vs. iterative solutions. 16 | 17 | --- 18 | 19 | ## Performance 20 | 21 | ### Recursion 22 | 23 | - **Pros**: Easier to implement for problems that naturally fit a recursive structure, like tree traversals. 24 | - **Cons**: May lead to stack overflow errors due to deep recursion. Higher space complexity due to function call stack. 25 | 26 | #### Example: Recursive Fibonacci 27 | 28 | ```javascript 29 | function fibonacci(n) { 30 | if (n <= 1) return n; 31 | return fibonacci(n - 1) + fibonacci(n - 2); 32 | } 33 | ``` 34 | ## Iteration 35 | Pros: More memory-efficient as it avoids the overhead of recursive function calls. Generally faster for most problems. 36 | Cons: Can be less intuitive for problems that have a natural recursive structure. 37 | 38 | #### Example: Iterative Fibonacci 39 | 40 | ```javascript 41 | function fibonacci(n) { 42 | let a = 0, b = 1; 43 | for (let i = 2; i <= n; i++) { 44 | [a, b] = [b, a + b]; 45 | } 46 | return b; 47 | } 48 | ``` 49 | ## Readability 50 | Recursion often results in cleaner and more understandable code for problems that involve hierarchical structures, while iteration may require additional variables and conditions. 51 | 52 | ## Conclusion 53 | Choosing between recursion and iteration depends on the specific problem you're tackling. Consider the trade-offs in performance and readability to make the best choice. 54 | -------------------------------------------------------------------------------- /blog/optimizing-recursive-functions.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: optimizing-recursive-functions 3 | title: "Optimizing Recursive Functions: Techniques and Tips" 4 | authors: [AKSHITHA-CHILUKA] 5 | tags: [AKSHITHA-CHILUKA, algo, dsa, algorithms, recursion, optimization] 6 | --- 7 | 8 | While recursion is a useful programming technique, it can lead to inefficiencies if not implemented correctly. Understanding how to optimize recursive functions is essential for better performance. 9 | 10 | 11 | 12 | In this blog, we’ll cover: 13 | 14 | - **Memoization**: Caching results to avoid redundant calculations. 15 | - **Tail Recursion**: A special case of recursion that can be optimized by the compiler. 16 | 17 | --- 18 | 19 | ## Memoization 20 | 21 | Memoization is an optimization technique where you store the results of expensive function calls and return the cached result when the same inputs occur again. 22 | 23 | ### Example: Fibonacci with Memoization 24 | 25 | ```javascript 26 | const memo = {}; 27 | function fibonacci(n) { 28 | if (n in memo) return memo[n]; 29 | if (n <= 1) return n; 30 | memo[n] = fibonacci(n - 1) + fibonacci(n - 2); 31 | return memo[n]; 32 | } 33 | ``` 34 | ### Tail Recursion 35 | Tail recursion is when a function calls itself as its last action. Some programming languages can optimize tail recursive calls to avoid adding a new stack frame. 36 | 37 | #### Example: Tail Recursive Factorial 38 | ```javascript 39 | function factorial(n, accumulator = 1) { 40 | if (n <= 1) return accumulator; 41 | return factorial(n - 1, n * accumulator); 42 | } 43 | ``` 44 | ## Conclusion 45 | By applying techniques like memoization and tail recursion, you can optimize your recursive algorithms for better performance, making your code faster and more efficient. 46 | -------------------------------------------------------------------------------- /blog/practical-applications-of-recursion.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: practical-applications-of-recursion 3 | title: Practical Applications of Recursion in Algorithms 4 | authors: [AKSHITHA-CHILUKA] 5 | tags: [AKSHITHA-CHILUKA , algo, dsa, algorithms, recursion] 6 | --- 7 | 8 | Recursion is more than just a theoretical concept; it has numerous practical applications across various algorithms. Understanding these applications can greatly enhance your programming skills. 9 | 10 | 11 | 12 | In this blog, we’ll discuss: 13 | 14 | - **Sorting Algorithms**: How recursion is used in sorting. 15 | - **Searching Algorithms**: The role of recursion in searching. 16 | 17 | --- 18 | 19 | ## Sorting Algorithms 20 | 21 | ### Quick Sort 22 | 23 | Quick Sort is a recursive sorting algorithm that works by selecting a 'pivot' element and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. 24 | 25 | #### Example: Quick Sort 26 | 27 | ```javascript 28 | function quickSort(arr) { 29 | if (arr.length <= 1) return arr; 30 | const pivot = arr[arr.length - 1]; 31 | const left = arr.slice(0, -1).filter(x => x < pivot); 32 | const right = arr.slice(0, -1).filter(x => x >= pivot); 33 | return [...quickSort(left), pivot, ...quickSort(right)]; 34 | } 35 | ``` 36 | # Searching Algorithms 37 | ## Binary Search 38 | Binary Search is a classic example of recursion in searching algorithms. It divides the search interval in half repeatedly until the target value is found. 39 | 40 | #### Example: Binary Search 41 | ```javacsript 42 | function binarySearch(arr, target) { 43 | function search(low, high) { 44 | if (low > high) return -1; 45 | const mid = Math.floor((low + high) / 2); 46 | if (arr[mid] === target) return mid; 47 | return arr[mid] > target ? search(low, mid - 1) : search(mid + 1, high); 48 | } 49 | return search(0, arr.length - 1); 50 | } 51 | ``` 52 | ## Conclusion 53 | Recursion is a powerful tool that finds applications in various sorting and searching algorithms. Mastering these practical uses can elevate your algorithmic skills. 54 | -------------------------------------------------------------------------------- /blog/understanding-big-o-notation.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: understanding-big-o-notation 3 | title: Understanding Big O Notation in Algorithm Analysis 4 | authors: [AKSHITHA-CHILUKA] 5 | tags: [AKSHITHA-CHILUKA , algo, dsa, algorithms, big-o, time-complexity] 6 | --- 7 | 8 | When analyzing algorithms, **Big O Notation** is a critical concept that helps us understand the performance and efficiency of an algorithm in terms of time and space complexity. 9 | 10 | 11 | 12 | In this blog, we’ll delve into: 13 | 14 | - **What is Big O Notation?**: An overview of the concept. 15 | - **Common Time Complexities**: Exploring the most frequent complexities. 16 | 17 | --- 18 | 19 | ## What is Big O Notation? 20 | 21 | Big O Notation describes the upper limit of an algorithm's growth rate, allowing us to express how the runtime or space requirements grow as the size of the input increases. 22 | 23 | ### Common Time Complexities: 24 | 25 | 1. **$O(1)$ - Constant Time** 26 | 2. **$O(n)$ - Linear Time** 27 | 3. **$O(log n)$ - Logarithmic Time** 28 | 4. **$O(n^2)$ - Quadratic Time** 29 | 30 | --- 31 | 32 | ## Example of Time Complexity Analysis 33 | 34 | Consider a simple loop that calculates the sum of an array: 35 | 36 | ```javascript 37 | function sumArray(arr) { 38 | let sum = 0; 39 | for (let num of arr) { 40 | sum += num; 41 | } 42 | return sum; 43 | } 44 | ``` 45 | The time complexity of this function is $O(n)$, where n is the length of the array. 46 | 47 | ## Space Complexity 48 | In addition to time complexity, it's essential to consider space complexity, which measures the amount of memory an algorithm uses relative to its input size. 49 | 50 | ## Conclusion 51 | Understanding Big O Notation is fundamental for analyzing algorithms and making informed decisions when selecting or designing them. By mastering this concept, you will improve your ability to evaluate algorithm performance effectively. 52 | -------------------------------------------------------------------------------- /docs/basic-data-structures/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Basic Data Structure", 3 | "position": 6, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Basic Data Structure. This is the first step to become a good programmer." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/basic-data-structures/array/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Arrays", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important concepts of Arrays." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/data-structures/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Data Structure", 3 | "position": 5, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Data Structure. This is the first step to become a good programmer." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/Convert Date to Binary.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: date-to-binary-conversion 3 | title: DSA Problem Solution 4 | sidebar_label: DSA Problem Solution 5 | sidebar-position: 1 6 | description: The "Date to Binary Conversion" problem on LeetCode typically involves converting a given date into its binary representation. 7 | tags: [DSA, leetcode, problem-solving] 8 | --- 9 | 10 | # Leetcode: Problem-3280 11 | 12 | ## Description: 13 | 14 | You are given a string ``date`` representing a Gregorian calendar date in the ``yyyy-mm-dd`` format. 15 | ``date`` can be written in its binary representation obtained by converting year, month, and day to their binary representations without any leading zeroes and writing them down in ``year-month-day`` format. 16 | Return the binary representation of ``date``. 17 | 18 | **Example 1:** 19 | Input: date = "2080-02-29" 20 | Output: "100000100000-10-11101" 21 | 22 | **Explanation:** 23 | 100000100000, 10, and 11101 are the binary representations of 2080, 02, and 29 respectively. 24 | 25 | **Example 2:** 26 | Input: date = "1900-01-01" 27 | Output: "11101101100-1-1" 28 | 29 | **Explanation:** 30 | 11101101100, 1, and 1 are the binary representations of 1900, 1, and 1 respectively. 31 | 32 | ## Steps: 33 | **1. Date Input:** Given a date in the format YYYY-MM-DD. 34 | 35 | **2. Binary Conversion:** 36 | 37 | • Convert the year (YYYY) to binary. 38 | • Convert the month (MM) to binary. 39 | • Convert the day (DD) to binary. 40 | 41 | **3. Output:** Provide the combined binary representation. 42 | 43 | # Solution in Java 44 | 45 | ```java 46 | class Solution { 47 | public String convertDateToBinary(String date) { 48 | String[] parts = date.split("-"); 49 | int year = Integer.parseInt(parts[0]); 50 | int month = Integer.parseInt(parts[1]); 51 | int day = Integer.parseInt(parts[2]); 52 | 53 | String yearBinary = Integer.toBinaryString(year); 54 | String monthBinary = Integer.toBinaryString(month); 55 | String dayBinary = Integer.toBinaryString(day); 56 | return yearBinary + "-" + monthBinary + "-" + dayBinary; 57 | } 58 | } 59 | ``` 60 | -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/Find Indices of stable mountains.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: find-indices-of-stable-mountains 3 | sidebar_position: 2 4 | title: Find Indices of stable mountains 5 | sidebar_label: Find Indices of stable mountains 6 | description: The "Find Indices of Stable Mountains" problem on involves identifying mountains that meet a specific stability criterion 1. 7 | tags: [dsa, algorithms, problem-solving] 8 | --- 9 | 10 | # Find Indices of Stable Mountains 11 | 12 | ## Description 13 | There are ``n`` mountains in a row, and each mountain has a height. You are given an integer array ``height`` where ``height[i]`` represents the height of mountain ``i``, and an integer ``threshold``. 14 | 15 | A mountain is called stable if the mountain just before it (if it exists) has a height strictly greater than ``threshold``. Note that mountain 0 is not stable. 16 | 17 | Return an array containing the indices of all stable mountains in any order. 18 | 19 | ### Example 1: 20 | 21 | **Input:** height = [1,2,3,4,5], threshold = 2 22 | 23 | **Output:** [3,4] 24 | 25 | **Explanation:** 26 | 27 | Mountain 3 is stable because height[2] == 3 is greater than threshold == 2. 28 | Mountain 4 is stable because height[3] == 4 is greater than threshold == 2. 29 | 30 | ### Example 2: 31 | 32 | **Input:** height = [10,1,10,1,10], threshold = 3 33 | 34 | **Output:** [1,3] 35 | 36 | ### Example 3: 37 | 38 | **Input:** height = [10,1,10,1,10], threshold = 10 39 | 40 | **Output:** [ ] 41 | 42 | ## Approach 43 | 44 | **1. Iterate Through Mountains:** Loop through the array starting from the second mountain. 45 | 46 | **2. Check Stability:** Compare the height of the current mountain with the height of the previous mountain. 47 | 48 | **3. Collect Stable Indices:** If the previous mountain's height is greater than the threshold, add the current mountain's index to the result list. 49 | 50 | # Code in Java 51 | 52 | ```java 53 | class Solution { 54 | public List stableMountains(int[] height, int threshold) { 55 | List stableMountains = new ArrayList<>(); 56 | for(int i=1; ithreshold) { 58 | stableMountains.add(i); 59 | } 60 | } 61 | return stableMountains; 62 | } 63 | } 64 | ``` 65 | 66 | 67 | -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/Palindrome-number.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: isPalindrome-problem 3 | title: DSA Problem Solution 4 | sidebar_label: DSA Problem Solution 5 | sidebar-position: 1 6 | description: A palindrome reads the same forwards and backwards, like "121" or "racecar." 7 | tags: [DSA, leetcode, problem-solving] 8 | --- 9 | 10 | ## Leetcode: Problem-9 11 | 12 | ### Description: 13 | 14 | Given an integer x, return true if x is a palindrome, and false otherwise. 15 | 16 | - **Example 1**: 17 | Input: x = 121 18 | Output: true 19 | Explanation: 121 reads as 121 from left to right and from right to left. 20 | 21 | - **Example 2**: 22 | Input: x = -121 23 | Output: false 24 | Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. 25 | 26 | - **Example 3**: 27 | Input: x = 10 28 | Output: false 29 | Explanation: Reads 01 from right to left. Therefore it is not a palindrome. 30 | 31 | ## Solution in Java: 32 | 33 | ```java 34 | public class Solution { 35 | public boolean isPalindrome(int x) { 36 | if (x < 0) { 37 | return false; // Negative numbers are not palindromes 38 | } 39 | int original = x; 40 | int reversed = 0; 41 | while (x != 0) { 42 | int digit = x % 10; //this returns the last digit 43 | reversed = reversed * 10 + digit; 44 | x /= 10; //x=x/10 which removes the last digit 45 | } 46 | return original == reversed; 47 | } 48 | public static void main(String args[]) { 49 | int x = 121; 50 | 51 | PalindromeChecker checker = new PalindromeChecker(); 52 | boolean result = checker.isPalindrome(x); 53 | 54 | if (result) { 55 | System.out.println(x + " is a palindrome."); 56 | } else { 57 | System.out.println(x + " is not a palindrome."); 58 | } 59 | } 60 | } 61 | ``` 62 | ## Output: 63 | 64 | ![Screenshot 2024-10-15 162332](https://github.com/user-attachments/assets/18ec353a-3920-4151-bfcb-1805f45b08d4) 65 | 66 | ## Analyze Complexity: 67 | 68 | ![Screenshot 2024-10-15 162602](https://github.com/user-attachments/assets/7dd17351-82b9-4863-b072-58dfcf6d806b) 69 | 70 | -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/Plus-one.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: plus-one 3 | sidebar_position: 2 4 | title: Plus One 5 | sidebar_label: Plus One 6 | description: The "Plus One" dsa problem is a classic algorithm challenge that involves manipulating an array of digits. The goal is to add one to a number represented by an array of its digits. 7 | tags: [dsa, algorithms, problem-solving] 8 | --- 9 | 10 | # Plus One 11 | 12 | ## Description 13 | You are given a large integer represented as an integer array ``digits``, where each ``digits[i]`` is the ``ith`` digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading ``0``'s. 14 | Increment the large integer by one and return the resulting array of digits. 15 | 16 | ### Example 1: 17 | 18 | **Input:** digits = [1,2,3] 19 | 20 | **Output:** [1,2,4] 21 | 22 | **Explanation:** The array represents the integer 123. 23 | 24 | Incrementing by one gives 123 + 1 = 124. 25 | 26 | Thus, the result should be [1,2,4]. 27 | 28 | ### Example 2: 29 | 30 | **Input:** digits = [4,3,2,1] 31 | 32 | **Output:** [4,3,2,2] 33 | 34 | **Explanation:** The array represents the integer 4321. 35 | 36 | Incrementing by one gives 4321 + 1 = 4322. 37 | 38 | Thus, the result should be [4,3,2,2]. 39 | 40 | ### Example 3: 41 | 42 | **Input:** digits = [9] 43 | 44 | **Output:** [1,0] 45 | 46 | **Explanation:** The array represents the integer 9. 47 | 48 | Incrementing by one gives 9 + 1 = 10. 49 | 50 | Thus, the result should be [1,0]. 51 | 52 | # Code in Java 53 | 54 | ```java 55 | class Solution { 56 | public int[] plusOne(int[] digits) { 57 | int n = digits.length; 58 | 59 | for(int i=n-1; i>=0; --i) { 60 | ++digits[i]; 61 | digits[i] = digits[i] % 10; 62 | if(digits[i] != 0) { 63 | return digits; 64 | } 65 | } 66 | digits = new int[n+1]; 67 | digits[0] = 1; 68 | return digits; 69 | } 70 | } 71 | ``` 72 | 73 | -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/house-robber.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: house-robber-algorithm 3 | title: House Robber Algorithm 4 | sidebar_label: Leetcode 198 5 | tags: [Leetcode, Dynamic Programming, DSA, House Robber] 6 | description: Solve the House Robber problem using dynamic programming to maximize the amount of money that can be robbed from houses without robbing two adjacent houses. 7 | --- 8 | 9 | # House Robber Algorithm 10 | 11 | ## Description 12 | 13 | The **House Robber** problem is a classic dynamic programming problem that focuses on maximizing the amount of money that can be robbed from houses lined up in a row, under the constraint that adjacent houses cannot be robbed. 14 | 15 | ### Problem Definition 16 | 17 | Given: 18 | - An array of integers `nums` where each element represents the amount of money in each house. 19 | 20 | Objective: 21 | - Determine the maximum amount of money that can be robbed without robbing two adjacent houses. 22 | 23 | ### Algorithm Overview 24 | 25 | 1. **Dynamic Programming Approach**: 26 | - Use a DP array where `dp[i]` represents the maximum amount of money that can be robbed from the first `i` houses. 27 | - Initialize: 28 | - `dp[0] = 0` (no houses to rob) 29 | - `dp[1] = nums[0]` (only one house) 30 | - For each house `i` from 2 to `n`: 31 | - Update `dp[i] = max(dp[i-1], dp[i-2] + nums[i-1])` 32 | - `dp[i-1]`: maximum amount without robbing the current house 33 | - `dp[i-2] + nums[i-1]`: maximum amount including the current house 34 | 35 | 2. **Return** `dp[n]`, the maximum amount that can be robbed. 36 | 37 | ### Time Complexity 38 | 39 | - **Time Complexity**: O(n), where n is the number of houses. 40 | - **Space Complexity**: O(n) for the DP array. 41 | 42 | ### C++ Implementation 43 | 44 | ```cpp 45 | #include 46 | using namespace std; 47 | 48 | int rob(vector& nums) { 49 | int n = nums.size(); 50 | if (n == 0) return 0; 51 | if (n == 1) return nums[0]; 52 | 53 | vector dp(n + 1); 54 | dp[0] = 0; 55 | dp[1] = nums[0]; 56 | 57 | for (int i = 2; i <= n; i++) { 58 | dp[i] = max(dp[i - 1], dp[i - 2] + nums[i - 1]); 59 | } 60 | 61 | return dp[n]; 62 | } 63 | ```` 64 | -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/longest_substring_without_repeated_characters.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: longest-substring-without-repeated-characters-problem 3 | sidebar_position: 4 4 | title: Longest Substring Without Repeating Characters 5 | sidebar_label: Longest Substring Without Repeating Characters 6 | description: "This document explains the 'Longest Substring Without Repeating Characters' problem, including its description, approach, and implementation." 7 | tags: [dsa, algorithms, problem-solving] 8 | --- 9 | 10 | # Longest Substring Without Repeating Characters 11 | 12 | ## Problem Statement 13 | Given a string, find the length of the longest substring without repeating characters. 14 | 15 | ## Approach 16 | We can use the `sliding window technique` along with a `hash map` to track the characters and their indices. 17 | 18 | ### Steps: 19 | 20 | 1. **Initialize**: 21 | - Create a hash map to store the last seen index of each character. 22 | - Initialize two pointers, `start` and `end`, to the beginning of the string. 23 | 24 | 25 | 2. **Iterate**: 26 | - For each character, check if it has been seen and is in the current window. 27 | - Update the `start` pointer if necessary. 28 | - Update the `end`. 29 | 30 | 3. **Return**: 31 | - Return the maximum length found. 32 | 33 | ## Python Implementation 34 | 35 | ```python 36 | class Solution: 37 | def lengthOfLongestSubstring(self, s: str) -> int: 38 | char_index = {} 39 | max_length = 0 40 | start = 0 41 | 42 | for i, char in enumerate(s): 43 | if char in char_index and char_index[char] >= start: 44 | start = char_index[char] + 1 45 | char_index[char] = i 46 | max_length = max(max_length, i - start + 1) 47 | 48 | return max_length 49 | 50 | ``` 51 | Time Complexity: O(n)
52 | Space Complexity: O(min(n, m)) (where m is the size of the character set) 53 | 54 | -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/merge_intervals.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: merge-intervals-problem 3 | sidebar_position: 3 4 | title: Merge Intervals 5 | sidebar_label: Merge Intervals 6 | description: "This document explains the Merge Intervals problem, including its description, approach, and implementation." 7 | tags: [dsa, algorithms, problem-solving] 8 | --- 9 | 10 | # Merge Intervals 11 | 12 | ## Problem Statement 13 | Given a collection of `intervals`, merge all overlapping intervals. 14 | 15 | ## Approach 16 | To merge the intervals, we can first sort them based on the start time. Then, we can iterate through the sorted intervals and merge them as needed. 17 | 18 | 19 | ### Steps: 20 | 21 | 1. **Initialize : Sort**: 22 | - Sort the intervals by their start times. 23 | - Initialize a list to hold the merged intervals. 24 | 25 | 2. **Iterate**: 26 | - For each interval, check if it overlaps with the last merged interval. 27 | - If it does, merge them. If not, add the interval to the list. 28 | 29 | 3. **Return**: 30 | - Return the merged intervals. 31 | 32 | ## Python Implementation 33 | 34 | ```python 35 | class Solution: 36 | def merge(self, intervals: List[List[int]]) -> List[List[int]]: 37 | if not intervals: 38 | return [] 39 | 40 | intervals.sort(key=lambda x: x[0]) 41 | merged = [intervals[0]] 42 | 43 | for i in range(1, len(intervals)): 44 | current = intervals[i] 45 | last_merged = merged[-1] 46 | 47 | if current[0] <= last_merged[1]: 48 | last_merged[1] = max(last_merged[1], current[1]) 49 | else: 50 | merged.append(current) 51 | 52 | return merged 53 | 54 | ``` 55 | Time Complexity: O(n log n)
56 | Space Complexity: O(n) -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/palindrome_linked_list.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: palindrome-linked-list-problem 3 | sidebar_position: 5 4 | title: Palindrome Linked List 5 | sidebar_label: Palindrome Linked List 6 | description: "This document explains the Palindrome Linked List problem, including its description, approach, and implementation." 7 | tags: [dsa, algorithms, problem-solving] 8 | --- 9 | 10 | # Palindrome Linked List 11 | 12 | ## Problem Statement 13 | Determine if a linked list is a palindrome. 14 | 15 | ## Approach 16 | To check if the linked list is a palindrome, we can use the fast and slow pointer technique to find the middle of the list, then reverse the second half and compare it with the first half. 17 | 18 | ### Steps: 19 | 20 | 1. **Find the Middle**: 21 | - Use two pointers to find the midpoint of the list 22 | 23 | 2. **Reverse the Second Half**: 24 | - Reverse the second half of the list. 25 | 26 | 3. **Compare**: 27 | - Compare the first half and the reversed second half. 28 | 29 | 4. **Return**: 30 | - Return true if they are equal; otherwise, return false. 31 | 32 | ## Python Implementation 33 | 34 | ```python 35 | class Solution: 36 | def isPalindrome(self, head: Optional[ListNode]) -> bool: 37 | if not head: 38 | return True 39 | 40 | # Step 1: Find the middle 41 | slow = fast = head 42 | while fast and fast.next: 43 | slow = slow.next 44 | fast = fast.next.next 45 | 46 | # Step 2: Reverse the second half 47 | prev = None 48 | while slow: 49 | next_node = slow.next 50 | slow.next = prev 51 | prev = slow 52 | slow = next_node 53 | 54 | # Step 3: Compare the two halves 55 | left, right = head, prev 56 | while right: # Only need to compare the second half 57 | if left.val != right.val: 58 | return False 59 | left = left.next 60 | right = right.next 61 | 62 | return True 63 | ``` 64 | Time Complexity: O(n)
65 | Space Complexity: O(1) -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/removing-stars-from-string.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: removing-stars-from-string 3 | sidebar_position: 1 4 | title: Removing Stars From a String 5 | sidebar_label: Removing Stars From a String 6 | description: "This document explains the Removing Stars From a String problem, including its description, approach, and implementation." 7 | tags: [dsa, algorithms, problem-solving] 8 | --- 9 | 10 | # Removing Stars From a String 11 | 12 | ## Description 13 | 14 | You are given a string `s`, which contains stars `*`. 15 | 16 | In one operation, you can: 17 | - Choose a star in `s`. 18 | - Remove the closest non-star character to its left, as well as remove the star itself. 19 | 20 | Return the string after all stars have been removed. 21 | 22 | ### Note: 23 | - The input will be generated such that the operation is always possible. 24 | - It can be shown that the resulting string will always be unique. 25 | 26 | ## Approach 27 | 28 | To solve this problem, we can use a **stack** to keep track of the non-star characters. We iterate through the string, and for each character: 29 | 1. If it is a non-star character, push it onto the stack. 30 | 2. If it is a star (`*`), pop the top element from the stack (i.e., remove the closest non-star character). 31 | 32 | Finally, the remaining elements in the stack represent the string after all stars and corresponding characters have been removed. 33 | 34 | ## Python Implementation 35 | 36 | ```python 37 | class Solution: 38 | def removeStars(self, s: str) -> str: 39 | stack = [] 40 | 41 | for char in s: 42 | if char == '*': 43 | if stack: 44 | stack.pop() # Remove the closest non-star character 45 | else: 46 | stack.append(char) 47 | 48 | return ''.join(stack) 49 | ``` 50 | Time Complexity: O(n)
51 | Space Complexity: O(n) -------------------------------------------------------------------------------- /docs/extra/DSA-Problem-Solution/two_sum.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: two-sum-problem 3 | sidebar_position: 2 4 | title: Two Sum 5 | sidebar_label: Two Sum 6 | description: "This document explains the Two Sum problem, including its description, approach, and implementation." 7 | tags: [dsa, algorithms, problem-solving] 8 | --- 9 | 10 | # Two Sum 11 | 12 | ## Problem Statement 13 | Given an array of integers `nums` and an integer `target`, return the indices of the two numbers such that they add up to `target`. 14 | 15 | ## Approach 16 | To solve this problem, we can use a hash map to store the numbers and their indices. As we iterate through the list, we check if the complement (target - current number) exists in the hash map. 17 | 18 | ### Steps: 19 | 20 | 1. **Initialize**: 21 | - Create an empty `hash` map. 22 | 23 | 2. **Iterate**: 24 | - For each number in `nums`, calculate its complement. 25 | - Check if the complement exists in the hash map. 26 | - If it exists, return the indices. 27 | - Otherwise, add the current number and its index to the hash map. 28 | 29 | 3. **Return**: 30 | - If no solution is found, return an empty list. 31 | 32 | ## Python Implementation 33 | 34 | ```python 35 | class Solution: 36 | def twoSum(self, nums: List[int], target: int) -> List[int]: 37 | num_map = {} 38 | for i, num in enumerate(nums): 39 | complement = target - num 40 | if complement in num_map: 41 | return [num_map[complement], i] 42 | num_map[num] = i 43 | ``` 44 | Time Complexity: O(n)
45 | Space Complexity: O(n) -------------------------------------------------------------------------------- /docs/extra/Hashing/OperationInsertion.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: insertion-in-hash-table 3 | sidebar_position: 1 4 | title: Insertion in Hash Table 5 | sidebar_label: Insertion in Hash Table 6 | description: "Insertion involves adding a key-value pair to the hash table. If the key already exists, it may update the existing value." 7 | tags: [hashing, data structures, insertion] 8 | --- 9 | 10 | ## Insertion in Hash Table 11 | 12 | The insertion operation in a hash table involves adding a key-value pair. Hashing is used to map the key to an index in the table. If the key already exists, the existing value can be updated. 13 | 14 | ### Steps for Insertion 15 | 16 | 1. **Hash the Key**: Use a hash function to convert the key into an index. 17 | 2. **Insert at the Computed Index**: Place the key-value pair at the index. If there's already data, resolve collisions via methods like chaining or open addressing. 18 | 3. **Update Value (if Key Exists)**: If the key already exists, update the associated value. 19 | 20 | ### Time Complexity 21 | - **Average Case**: $O(1)$ 22 | - **Worst Case**: $O(n)$ (if many collisions occur) 23 | 24 | ### Example Code (Python) 25 | 26 | ```python 27 | class HashTable: 28 | def __init__(self): 29 | self.table = {} 30 | 31 | def insert(self, key, value): 32 | self.table[key] = value 33 | 34 | # Example usage 35 | hash_table = HashTable() 36 | hash_table.insert('apple', 10) 37 | hash_table.insert('banana', 20) 38 | hash_table.insert('apple', 30) # Updates value 39 | ``` 40 | 41 | ### Conclusion 42 | 43 | Insertion is a fundamental operation in hash tables, allowing for efficient data storage and retrieval, especially when handling key-value pairs. 44 | -------------------------------------------------------------------------------- /docs/extra/Hashing/OperationSearch.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: search-in-hash-table 3 | sidebar_position: 3 4 | title: Search in Hash Table 5 | sidebar_label: Search in Hash Table 6 | description: "Search involves retrieving the value associated with a given key in the hash table." 7 | tags: [hashing, data structures, search] 8 | --- 9 | 10 | ## Search in Hash Table 11 | 12 | The search operation involves retrieving the value associated with a key in a hash table. Hashing ensures efficient lookups based on the key. 13 | 14 | ### Steps for Search 15 | 16 | 1. **Hash the Key**: Use the hash function to determine the index. 17 | 2. **Check for Key**: If the key exists at the computed index, return the corresponding value. 18 | 3. **Handle Collision**: Properly handle cases where multiple keys map to the same index. 19 | 20 | ### Time Complexity 21 | - **Average Case**: $O(1)$ 22 | - **Worst Case**: $O(n)$ 23 | 24 | ### Example Code (Python) 25 | 26 | ```python 27 | class HashTable: 28 | def __init__(self): 29 | self.table = {} 30 | 31 | def search(self, key): 32 | return self.table.get(key, None) 33 | 34 | # Example usage 35 | hash_table = HashTable() 36 | hash_table.table = {'apple': 10, 'banana': 20} 37 | print(hash_table.search('apple')) # Output: 10 38 | ``` 39 | ### Example Code (JavaScript) 40 | 41 | ```javascript 42 | class HashTable { 43 | constructor() { 44 | this.table = {}; 45 | } 46 | 47 | // Method to search for a key in the hash table 48 | search(key) { 49 | return this.table.hasOwnProperty(key) ? this.table[key] : null; 50 | } 51 | } 52 | 53 | // Example usage 54 | const hashTable = new HashTable(); 55 | hashTable.table = { apple: 10, banana: 20 }; 56 | console.log(hashTable.search('apple')); // Output: 10 57 | ``` 58 | 59 | 60 | ### Conclusion 61 | 62 | Search is one of the primary operations in a hash table, allowing fast retrieval of data associated with a key. 63 | -------------------------------------------------------------------------------- /docs/extra/Hashing/OperationUpdate.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: update-in-hash-table 3 | sidebar_position: 4 4 | title: Update in Hash Table 5 | sidebar_label: Update in Hash Table 6 | description: "Update involves modifying the value associated with an existing key in the hash table." 7 | tags: [hashing, data structures, update] 8 | --- 9 | 10 | ## Update in Hash Table 11 | 12 | The update operation involves modifying the value associated with an existing key in a hash table. If the key is not present, it may require an insertion. 13 | 14 | ### Steps for Update 15 | 16 | 1. **Hash the Key**: Use a hash function to find the index. 17 | 2. **Update the Value**: Modify the value associated with the key if it exists. 18 | 3. **Handle Key Absence**: If the key does not exist, you can choose to insert it instead. 19 | 20 | ### Time Complexity 21 | - **Average Case**: $O(1)$ 22 | - **Worst Case**: $O(n)$ 23 | 24 | ### Example Code (Python) 25 | 26 | ```python 27 | class HashTable: 28 | def __init__(self): 29 | self.table = {} 30 | 31 | def update(self, key, value): 32 | self.table[key] = value 33 | 34 | # Example usage 35 | hash_table = HashTable() 36 | hash_table.table = {'apple': 10, 'banana': 20} 37 | hash_table.update('apple', 30) # Updates value 38 | ``` 39 | 40 | ### Example Code (Javascript) 41 | 42 | ```javascript 43 | class HashTable { 44 | constructor() { 45 | this.table = {}; 46 | } 47 | 48 | update(key, value) { 49 | this.table[key] = value; 50 | } 51 | } 52 | 53 | // Example usage 54 | const hashTable = new HashTable(); 55 | hashTable.table = { 'apple': 10, 'banana': 20 }; 56 | hashTable.update('apple', 30); // Updates the value for 'apple' 57 | console.log(hashTable.table); // Output: { 'apple': 30, 'banana': 20 } 58 | ``` 59 | 60 | ### Conclusion 61 | 62 | Update is critical for modifying data in hash tables, making them adaptable and suitable for dynamic applications. 63 | -------------------------------------------------------------------------------- /docs/extra/Hashing/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Hashing in DSA", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Hashing is a crucial technique in data structures and algorithms (DSA) that provides efficient ways to store, retrieve, and manage data. It is widely used in competitive programming to solve problems involving searching, duplicates, and efficient data access, thanks to constant-time complexity in ideal cases." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/KMP searching pattern/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "KMP searching pattern", 3 | "position": 5, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "The KMP algorithm is a string searching algorithm that uses a prefix table to skip over unnecessary comparisons when searching for a pattern in a text." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/Object Oriented Programming/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Object-Oriented Programming (OOPs) Concepts", 3 | "position": 8, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Object-Oriented Programming (OOPs) is a programming paradigm based on the concept of objects, which can contain data and code. OOPs promotes the principles of encapsulation, inheritance, polymorphism, and abstraction. It is widely used in modern software development to create modular, reusable, and scalable code, making it easier to maintain and extend applications." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/Object Oriented Programming/car.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Object Oriented Programming/car.png -------------------------------------------------------------------------------- /docs/extra/Object Oriented Programming/intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Object Oriented Programming/intro.png -------------------------------------------------------------------------------- /docs/extra/Queue/Blocked-queue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Queue/Blocked-queue.png -------------------------------------------------------------------------------- /docs/extra/Queue/Circular-queue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Queue/Circular-queue.png -------------------------------------------------------------------------------- /docs/extra/Queue/Priority-queue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Queue/Priority-queue.png -------------------------------------------------------------------------------- /docs/extra/Queue/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Queue", 3 | "position": 10, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important and widely used concepts of Queue." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/Queue/doubleendedqueue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Queue/doubleendedqueue.png -------------------------------------------------------------------------------- /docs/extra/Recursion-depths/performance-consideration.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: recursion-depth-performance 3 | title: Recursion Depth and Performance 4 | sidebar_label: Performance Considerations 5 | sidebar_position: 4 6 | description: Understanding how recursion depth affects algorithm performance. 7 | tags: [performance, recursion, optimization] 8 | --- 9 | 10 | 11 | # Recursion Depth and Performance 12 | 13 | Recursion depth can affect the performance and efficiency of your program. High depths increase memory usage and may lead to stack overflows. Here are ways to optimize recursive functions. 14 | 15 | ## Optimizing Recursive Functions 16 | 1. **Tail Recursion**: Some languages optimize tail-recursive functions to reduce stack usage. 17 | 2. **Memoization**: Store previous results to reduce duplicate calls, especially in algorithms like Fibonacci. 18 | 3. **Iterative Solutions**: Convert recursive functions to iterative when feasible. 19 | 20 | ## Example 21 | In cases like calculating large Fibonacci numbers, use memoization to reduce depth. 22 | -------------------------------------------------------------------------------- /docs/extra/Recursion/Count-all-subsequences-with-sum-K.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: count-all-subsequences-with-sum-k-problem-dsa 3 | title: Perfect sum 4 | sidebar_label: Perfect sum 5 | description: "The Perfect Sum problem involves finding all subsets of an array that sum up to a given target sum. The solution uses recursion and dynamic programming to efficiently count subsets with a specified sum while handling large values using modulo." 6 | tags: [perfect-sum, recursion, dynamic-programming, dsa] 7 | --- 8 | 9 | ## Perfect Sum Problem | Count All Subsets with Sum k 10 | 11 | - Problem Statement: Given an array arr of size n of non-negative integers and an integer sum, the task is to count all subsets of the given array with a sum equal to the target sum. Due to potentially large outputs, the answer must be computed modulo 10^9+7. 12 | 13 | ``` 14 | - Input: 15 | n = 6, arr = [5, 2, 3, 10, 6, 8], sum = 10 16 | - Output: 3 17 | - Explanation: The subsets that sum to 10 are {5, 2, 3}, {2, 8}, and {10}. 18 | ``` 19 | 20 | - Expected Time Complexity: 𝑂(𝑛×sum) 21 | 22 | - Expected Auxiliary Space: 𝑂(𝑛×sum) 23 | 24 | ### C++ Implementation 25 | 26 | ```cpp 27 | #include 28 | using namespace std; 29 | 30 | class Solution { 31 | public: 32 | int countSum(int arr[], int i, int n, int total, int sum, int mod) { 33 | if (i == n) { 34 | return (total == sum) ? 1 : 0; 35 | } 36 | return (countSum(arr, i + 1, n, (total + arr[i]) % mod, sum, mod) + 37 | countSum(arr, i + 1, n, total, sum, mod)) % mod; 38 | } 39 | 40 | int perfectSum(int arr[], int n, int sum) { 41 | int mod = 1e9 + 7; // Modulo value as given in the problem statement 42 | return countSum(arr, 0, n, 0, sum, mod); 43 | } 44 | }; 45 | 46 | int main() { 47 | Solution solution; 48 | int n = 6; 49 | int arr[] = {5, 2, 3, 10, 6, 8}; 50 | int sum = 10; 51 | cout << "Number of subsets with sum " << sum << ": " 52 | << solution.perfectSum(arr, n, sum) << endl; 53 | return 0; 54 | } 55 | ``` 56 | -------------------------------------------------------------------------------- /docs/extra/Recursion/N Queen 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Recursion/N Queen 2.png -------------------------------------------------------------------------------- /docs/extra/Recursion/N Qween 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Recursion/N Qween 1.png -------------------------------------------------------------------------------- /docs/extra/Recursion/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Recursion", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Recursion is a programming technique where a function calls itself directly or indirectly in order to solve a larger problem by breaking it down into smaller, more manageable sub-problems. It is commonly used in algorithms involving divide and conquer strategies, tree traversal, and dynamic programming." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/Recursion/josephus.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: Josephus-problem-dsa 3 | title: Josephus Problem Recursion 4 | sidebar_label: Josephus Problem 5 | sidebar_position: 7 6 | description: "The Josephus problem is a theoretical problem related to a certain elimination game. It is often solved using recursion, where the goal is to determine the safe position in a group of people standing in a circle, eliminating every k-th person." 7 | tags: [josephus, recursion, dsa] 8 | --- 9 | 10 | ## Josephus Problem | Return the Safe Position 11 | 12 | Problem Statement: The Josephus problem is a famous theoretical problem. There are n people standing in a circle, and every k-th person is eliminated until only one person remains. The task is to find the position of the last person standing (safe position). The positions are numbered from 0 to n-1. 13 | Recursive Solution 14 | The idea is to use a recursive approach to find the position of the safe person. We know that when only one person remains, the safe position is 0. Then we build the solution backwards, considering the elimination of every k-th person. 15 | 16 | Recursive Solution 17 | The idea is to use a recursive approach to find the position of the safe person. We know that when only one person remains, the safe position is 0. Then we build the solution backwards, considering the elimination of every k-th person. 18 | 19 | ### C++ implementation 20 | ```cpp 21 | #include 22 | using namespace std; 23 | 24 | class Josephus { 25 | public: 26 | // Recursive function to find the safe position 27 | int josephus(int n, int k) { 28 | // Base case: only one person is left 29 | if (n == 1) 30 | return 0; 31 | 32 | // Recursive case: Reduce the problem by eliminating one person 33 | // The position returned by josephus(n-1, k) is adjusted for the new circle size. 34 | return (josephus(n - 1, k) + k) % n; 35 | } 36 | }; 37 | 38 | int main() { 39 | int n = 7; // Total number of people in the circle 40 | int k = 3; // Every k-th person is eliminated 41 | 42 | Josephus obj; 43 | int safe_position = obj.josephus(n, k); 44 | 45 | cout << "The safe position is: " << safe_position << endl; 46 | return 0; 47 | } 48 | ``` -------------------------------------------------------------------------------- /docs/extra/Segment-Trees/Segment-Tree-img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Segment-Trees/Segment-Tree-img.png -------------------------------------------------------------------------------- /docs/extra/Sliding-Window/IntroductionToSlidingWindow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Sliding-Window/IntroductionToSlidingWindow.jpg -------------------------------------------------------------------------------- /docs/extra/Sliding-Window/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Sliding Window", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "The Sliding Window is an efficient technique used to solve problems involving arrays or strings where we need to find a subrange that satisfies a particular condition. Instead of recomputing the entire range from scratch every time, we slide a window over the array/string and update the solution incrementally." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/Stack/Introduction_to_Stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Stack/Introduction_to_Stack.png -------------------------------------------------------------------------------- /docs/extra/Stack/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Stacks", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "A stack is a linear data structure that follows the Last In First Out (LIFO) principle. It allows operations to be performed at one end, called the top of the stack, making it efficient for scenarios such as expression evaluation, backtracking algorithms, and function call management." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/Tarjan's Algorithm/algorithm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/Tarjan's Algorithm/algorithm.png -------------------------------------------------------------------------------- /docs/extra/Task Scheduling/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Task Scheduling", 3 | "position": 9, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Task Scheduling involves arranging tasks in a sequence based on dependencies, ensuring that all prerequisite tasks are completed before a dependent task begins. It uses algorithms like Topological Sorting to determine feasible schedules for tasks in a Directed Acyclic Graph (DAG)." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/Tries/Problem-Practice.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: Practice-Problems-on-tries 3 | title: Practice Problems 4 | sidebar_label: Practice Problems 5 | sidebar_position: 2 6 | description: Here are some practice problems for tries 7 | tags: [DSA, algorithms, tries] 8 | --- 9 | 10 | ### Problems on tries: 11 | 12 | - [Implement trie](https://leetcode.com/problems/implement-trie-prefix-tree/description/) 13 | - [Implement trie-2](https://leetcode.com/problems/implement-trie-ii-prefix-tree/description/) 14 | - [Longest word with all prefixes](https://leetcode.com/problems/longest-word-with-all-prefixes/description/) 15 | - [Number of distinct substrings in a string](https://leetcode.com/problems/number-of-distinct-substrings-in-a-string/description/) 16 | - [Maximum XOR of 2 numbers in an array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/description/) 17 | - [Maximum xor with an element from array](https://leetcode.com/problems/maximum-xor-with-an-element-from-array/description/) 18 | - [Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs/description/) 19 | - [Phone directory](https://www.geeksforgeeks.org/problems/phone-directory4628/1) 20 | - [Print Anagrams Together](https://www.geeksforgeeks.org/problems/print-anagrams-together/1) 21 | - [Design Add and Search Words Data Structure](https://leetcode.com/problems/design-add-and-search-words-data-structure/description/) 22 | - [Word Break (Trie)](https://www.geeksforgeeks.org/problems/word-break-trie--141631/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) -------------------------------------------------------------------------------- /docs/extra/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Extra", 3 | "position": 99, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Programming Fundamentals. This is the first step to become a good programmer." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/advance-data-structure/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Advanced Data Structures", 3 | "position": 9, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Discover the key roadmap for mastering advanced data structure concepts and techniques." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/algorithms/DutchNationalFlag-algorithm/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Dutch National Flag Algorithm", 3 | "position": 5, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn Dutch National Flag Algorithm." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/Scheduling Algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Scheduling Algorithms", 3 | "position": 3, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about some Scheduling Algorithms." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/Two-Pointers/IntroductionToTwoPointers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/algorithms/Two-Pointers/IntroductionToTwoPointers.png -------------------------------------------------------------------------------- /docs/extra/algorithms/Two-Pointers/Problem-Practice.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: Practice-Problems-on-two-pointers 3 | title: Practice Problems 4 | sidebar_label: Practice Problems 5 | sidebar_position: 3 6 | description: Here are some practice problems for the Two Pointers technique, divided into topic-wise and difficulty-wise categories. 7 | tags: [DSA, algorithms, two pointers] 8 | --- 9 | 10 | ### Basic Two Pointers Problems: 11 | 12 | - [Two Sum](https://leetcode.com/problems/two-sum/) 13 | - [3Sum](https://leetcode.com/problems/3sum/) 14 | - [Container With Most Water](https://leetcode.com/problems/container-with-most-water/) 15 | - [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/) 16 | - [Valid Palindrome II](https://leetcode.com/problems/valid-palindrome-ii/) 17 | 18 | ### Advanced Two Pointers Problems: 19 | 20 | - [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/) 21 | - [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number/) 22 | - [Pair Sum in an Array](https://leetcode.com/problems/pair-sum-in-an-array/) 23 | - [Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum/) 24 | 25 | ### Sliding Window with Two Pointers: 26 | 27 | - [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) 28 | - [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/) 29 | - [Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement/) 30 | - [Subarray Product Less Than K](https://leetcode.com/problems/subarray-product-less-than-k/) 31 | 32 | ### Challenges: 33 | 34 | - [Maximum Area of Island](https://leetcode.com/problems/maximum-area-of-island/) 35 | - [Find First and Last Position of Element in Sorted Array](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/) 36 | -------------------------------------------------------------------------------- /docs/extra/algorithms/Two-Pointers/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Two Pointers Algorithms", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "In this blog post, we'll explore the Two Pointers Algorithm, an efficient technique for solving problems related to arrays or strings." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Algorithms", 3 | "position": 8, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important RoadMap for Basic Concepts of Data Structures and Algorithms." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/backtracking-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Backtracking Algorithms", 3 | "position": 6, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Backtracking is an essential algorithmic technique for solving problems recursively by trying to build a solution incrementally. Explore various backtracking algorithms and their applications in solving complex computational problems like N-Queens, Sudoku, Subset Sum, and more." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/algorithms/backtracking-algorithms/imp-of-backtracking.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: importance-of-backtracking 3 | sidebar_position: 2 4 | title: Importance of Backtracking 5 | sidebar_label: Importance of Backtracking 6 | description: "Backtracking is a systematic algorithmic method for solving problems where you need to explore all possible configurations (solution candidates) and discard those that fail to satisfy the given constraints. It is widely used to solve constraint satisfaction problems such as puzzles, combinatorial optimization problems, and decision problems." 7 | tags: [CSPs, Optimization] 8 | --- 9 | 10 | ### Importance of Backtracking Algorithms 11 | 12 | 1. **Solving Constraint Satisfaction Problems (CSPs)**: 13 | Backtracking is a go-to technique for solving problems that involve a set of constraints, such as Sudoku, crosswords, and puzzles. It systematically searches for solutions and eliminates configurations that don’t meet the criteria early on, which makes it efficient for such problems. 14 | 15 | 2. **Combinatorial Search**: 16 | Backtracking is ideal for combinatorial problems, such as finding all subsets of a set, generating permutations, or solving problems where you have to find a particular arrangement of elements that satisfies given constraints. 17 | 18 | 3. **Optimization**: 19 | In problems like the N-Queens problem or traveling salesperson problem (TSP), backtracking can be combined with techniques like branch-and-bound to further improve efficiency by cutting off search branches early. 20 | 21 | 4. **Efficiently Navigating Large Search Spaces**: 22 | Backtracking helps navigate large search spaces without having to examine every possibility by pruning unfeasible solutions early on. 23 | -------------------------------------------------------------------------------- /docs/extra/algorithms/greedy-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Greedy Algorithms", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Greedy algorithms are a paradigm for solving optimization problems. The main idea behind a greedy algorithm is to make a sequence of choices, each of which looks the best at the moment. It chooses the optimal solution at every step with the hope that these local optimal choices will lead to a global optimal solution." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/algorithms/kadane-algorithm/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Kadane's Algorithm", 3 | "position": 10, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important and widely used concepts of Kadane's Algorithm." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/mathematics-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Mathematical Algorithms", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Mathematical algorithms are essential in computer science for solving problems that require mathematical computations and reasoning. These algorithms are foundational in various applications, from cryptography to statistical analysis, and play a significant role in competitive programming." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/memoisation-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Memoization Algorithms", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Memoization is an optimization technique used primarily to speed up recursive algorithms by caching previously computed results. It is widely used in dynamic programming to avoid redundant calculations, significantly improving performance for problems such as the Fibonacci sequence, shortest paths, and other combinatorial problems." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/algorithms/recursive-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Recursive Algorithms", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about some Recursive Algorithms." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/sorting-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Sorting Algorithms", 3 | "position": 2, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about some Sorting Algorithms." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/algorithms/string-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "String Algorithms", 3 | "position": 3, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about some String Algorithms." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/b-tree/image/BTree2Ins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/BTree2Ins.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/BTreeIns3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/BTreeIns3.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/BTreeIns4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/BTreeIns4.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/BTreeIns6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/BTreeIns6.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/BTreeSplit-1024x321.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/BTreeSplit-1024x321.jpg -------------------------------------------------------------------------------- /docs/extra/b-tree/image/Btree1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/Btree1.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/delete.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/delete2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/delete2.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/output253.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/output253.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/output254.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/output254.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/output255.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/output255.png -------------------------------------------------------------------------------- /docs/extra/b-tree/image/output256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/b-tree/image/output256.png -------------------------------------------------------------------------------- /docs/extra/balancedBinTree/balancedBinTree.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: balanced-binary-tree-checker-python 3 | title: Balanced Binary Tree Checker in Python 4 | sidebar_label: Balanced Binary Tree (Python) 5 | sidebar_position: 4 6 | description: Implement a solution to check if a binary tree is balanced using Python 7 | tags: [python, binary-tree, tree-traversal, recursion, depth-first-search] 8 | --- 9 | 10 | # Balanced Binary Tree Checker 11 | 12 | This document provides a Python implementation of a binary tree and a method to check if the tree is balanced. 13 | 14 | ## Implementation 15 | 16 | ```python 17 | class Node: 18 | def __init__(self, val): 19 | self.data = val 20 | self.left = None 21 | self.right = None 22 | 23 | class Solution: 24 | def isBalanced(self, root): 25 | return self.dfsHeight(root) != -1 26 | 27 | def dfsHeight(self, root): 28 | if not root: 29 | return 0 30 | 31 | left_height = self.dfsHeight(root.left) 32 | if left_height == -1: 33 | return -1 34 | 35 | right_height = self.dfsHeight(root.right) 36 | if right_height == -1: 37 | return -1 38 | 39 | if abs(left_height - right_height) > 1: 40 | return -1 41 | 42 | return max(left_height, right_height) + 1 43 | ``` 44 | # Creating a sample binary tree 45 | ``` 46 | root = Node(1) 47 | root.left = Node(2) 48 | root.right = Node(3) 49 | root.left.left = Node(4) 50 | root.left.right = Node(5) 51 | root.left.right.right = Node(6) 52 | root.left.right.right.right = Node(7) 53 | 54 | # Creating an instance of the Solution class 55 | solution = Solution() 56 | 57 | # Checking if the tree is balanced 58 | if solution.isBalanced(root): 59 | print("The tree is balanced.") 60 | else: 61 | print("The tree is not balanced.") 62 | ``` -------------------------------------------------------------------------------- /docs/extra/basic-dsa/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Basic Data Structures and Algorithms", 3 | "position": 6, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important RoadMap for Basic Concepts of Data Structures and Algorithms." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/basic-dsa/array/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Arrays", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important concepts of Arrays." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/binary-search-tree/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Binary Search Tree", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "A **Binary Search Tree (BST)** is a type of binary tree where each node follows a specific ordering property: 1. All the values in the left subtree are less than the root node. 2. All the values in the right subtree are greater than the root node." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/binary-search/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Binary Search", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Binary search is a searching algorithm, used to search for an element in an array. It follows a unique approach which reduces the time complexity as compared to linear search. However, to use binary search, the array must be sorted." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/binary-trees/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Binary Trees", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Binary trees are a fundamental data structure used to represent hierarchical relationships between elements. Each node in a binary tree has at most two children, referred to as the left child and the right child. This structure allows for efficient searching, insertion, and deletion operations, making binary trees an essential concept in computer science." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/bit-manipulation/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Bit Manipulation", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Bit manipulation involves operating directly on binary digits or bits, which are the most basic units of data in computing. Bit manipulation is used in low-level programming tasks where performance and memory efficiency are crucial. This documentation covers key concepts, operations, and techniques in bit manipulation." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/bit-manipulation/clear-ith-Bit.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: clear-ith-bit 3 | tittle: Clear ith Bit 4 | sidebar-level: Clear ith Bit 5 | sidebar-position: 2 6 | Description: Clearing the i-th bit in a number is a nifty bit manipulation technique. This involves setting the i-th bit to 0, leaving all other bits unchanged. 7 | tags: [dsa, bit manipulation, clear bits] 8 | --- 9 | 10 | # Description 11 | 12 | Clearing the i-th bit in a number is a common bit manipulation technique. This operation involves setting the i-th bit to 0 while leaving all other bits unchanged. 13 | 14 | ## Steps to Clear the i-th Bit 15 | **1. Create a Mask:** Create a number that has all bits set to 1 except for the i-th bit, which is set to 0. 16 | 17 | **2. AND Operation:** Perform a bitwise AND between the original number and the mask. This will clear the i-th bit while keeping all other bits unchanged. 18 | 19 | ## Formula 20 | > `mask =∼ (1<<𝑖)` 21 | 22 | > `result = num&mask` 23 | 24 | 25 | # Code in Java 26 | ```java 27 | import java.util.*; 28 | 29 | public class clearIthBit { 30 | 31 | public static int clearIthBit(int n, int i) { 32 | int bitMask = ~(1< 37 | #include 38 | using namespace std; 39 | 40 | int minFlipsToZeroMatrix(vector>& matrix) { 41 | int m = matrix.size(); 42 | int n = matrix[0].size(); 43 | int flips = 0; 44 | 45 | // Count the number of 1's in the matrix 46 | for (int i = 0; i < m; i++) { 47 | for (int j = 0; j < n; j++) { 48 | flips += matrix[i][j]; 49 | } 50 | } 51 | 52 | // The number of flips required is equal to the number of 1's 53 | return flips; 54 | } 55 | 56 | int main() { 57 | vector> matrix = {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}; 58 | cout << "Minimum flips required: " << minFlipsToZeroMatrix(matrix) << endl; 59 | return 0; 60 | } 61 | ``` -------------------------------------------------------------------------------- /docs/extra/fundamentals/Functions/Function Return.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: function-return 3 | title: Function Return 4 | sidebar_label: Function Return 5 | sidebar_position: 4 6 | description: Learn about how functions return values in various programming languages. 7 | tags: [functions, fundamentals, programming fundamentals, return_values] 8 | --- 9 | 10 | ## Overview 11 | A **function return** specifies the value or result that a function sends back to the part of the program that called it. The return value is used to pass a result from the function execution to its caller. If no return value is specified, some languages return a default value (such as `void` in C++ or `None` in Python). 12 | 13 | 14 | ## Syntax 15 | ### C++ 16 | ```c++ 17 | // Function returning a value 18 | return_type function_name(parameter1_type parameter1) { 19 | // function body 20 | return value; 21 | } 22 | ``` 23 | 24 | ## Example 25 | ### C++ Example 26 | ```c++ 27 | // Function returning an integer 28 | int add(int a, int b) { 29 | return a + b; 30 | } 31 | 32 | // Function call and storing the return value 33 | int result = add(10, 20); // result is now 30 34 | ``` 35 | 36 | 37 | 38 | ## Syntax 39 | ### Python 40 | ```py 41 | # Function returning a value 42 | def function_name(parameter1): 43 | # function body 44 | return value 45 | 46 | ``` 47 | 48 | ## Example 49 | ### Python Example 50 | ```py 51 | # Function returning a value 52 | def add(a, b): 53 | return a + b 54 | 55 | # Function call and storing the return value 56 | result = add(10, 20) # result is now 30 57 | ``` 58 | 59 | 60 | 61 | 62 | ## Key Points: 63 | 1. Return value is the result that a function sends back to the caller after its execution. 64 | 2. In C++, the return type is declared in the function signature (e.g., int for returning integers, void for no return value). 65 | 3. Python functions return None if no explicit return statement is provided. 66 | 4. The return keyword is used in both C++ and Python to send a value back to the caller. 67 | 5. Multiple values can be returned from a function in some languages (e.g., using tuples in Python). 68 | 69 | 70 | -------------------------------------------------------------------------------- /docs/extra/graphs/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Graphs", 3 | "position": 11, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important concepts of Graph." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/graphs/shortest-path-algorithms/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Shortest Path Algorithms", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important Shortest Path Algorithms." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/extra/hash/Practice Problems.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: practice-problems-on-hash-tables 3 | title: Practice Problems 4 | sidebar_label: Practice Problems 5 | sidebar_position: 16 6 | Description: Here are some practice problems for Hash Table divided into topic-wise and difficulty wise. 7 | tags: [DSA, algorithms,hash-table, dsa] 8 | --- 9 | 10 | ### 1. Easy Level 11 | 12 | - [Ransom Note](https://leetcode.com/problems/ransom-note/description/) 13 | - [Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings/description/) 14 | - [Word Pattern](https://leetcode.com/problems/word-pattern/description/) 15 | - [Valid Anagram](https://leetcode.com/problems/valid-anagram/description/) 16 | - [Two Sum](https://leetcode.com/problems/two-sum/description/) 17 | - [Happy Number](https://leetcode.com/problems/happy-number/description/) 18 | - [Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii/description/) 19 | - [Find the Difference of Two Arrays](https://leetcode.com/problems/find-the-difference-of-two-arrays/description/) 20 | - [Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences/description/) 21 | 22 | --- 23 | 24 | ### 2. Medium Level 25 | 26 | - [Group Anagrams](https://leetcode.com/problems/group-anagrams/description/) 27 | - [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence/description/) 28 | - [Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close/description/) 29 | - [Equal Row and Column Pairs](https://leetcode.com/problems/equal-row-and-column-pairs/description/) 30 | 31 | --- 32 | 33 | ### 3. Hard Level 34 | 35 | - [Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words/description) 36 | - [First Missing Positive](https://leetcode.com/problems/first-missing-positive/description/) 37 | - [Sudoku Solver](https://leetcode.com/problems/sudoku-solver/description/) 38 | - [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/description/) 39 | 40 | --- 41 | -------------------------------------------------------------------------------- /docs/extra/hash/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Hash tables", 3 | "position": 14, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "A Hash Table is a data structure designed to be fast to work with." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/heap/Problem-Practice.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: Practice-Problems-on-heap 3 | title: Practice Problems 4 | sidebar_label: Practice Problems 5 | sidebar_position: 2 6 | description: Here are some practice problems for heaps, divided into topic-wise and difficulty-wise categories. 7 | tags: [DSA, algorithms, heaps] 8 | --- 9 | 10 | ### Basic Problems: 11 | 12 | - [kth largest element in an array](https://leetcode.com/problems/kth-largest-element-in-an-array/description/) 13 | - [Does array represent Heap](https://www.geeksforgeeks.org/problems/does-array-represent-heap4345/1?utm_source=youtube&utm_medium=collab_striver_ytdescription&utm_campaign=does-array-represent-heap) 14 | - [Sum of elements between k1'th and k2'th smallest elements](https://www.geeksforgeeks.org/problems/sum-of-elements-between-k1th-and-k2th-smallest-elements3133/0) 15 | - [Heap sort](https://leetcode.com/problems/sort-an-array/description/) 16 | 17 | ### Intermediate Problems: 18 | 19 | - [Merge K sorted lists](https://leetcode.com/problems/merge-k-sorted-lists/description/) 20 | - [Task Scheduler](https://leetcode.com/problems/task-scheduler/description/) 21 | - [Hand of Straights](https://leetcode.com/problems/hand-of-straights/description/) 22 | - [BST to max heap](https://www.geeksforgeeks.org/problems/bst-to-max-heap/1) 23 | - [Merge overlapping intervals](https://leetcode.com/problems/merge-intervals/description/) 24 | 25 | ### Advanced Problems: 26 | 27 | - [Design Twitter](https://leetcode.com/problems/design-twitter/description/) 28 | - [kth largest element in a stream](https://leetcode.com/problems/kth-largest-element-in-a-stream/description/) 29 | - [Find median from data stream](https://leetcode.com/problems/find-median-from-data-stream/description/) 30 | - [Top k frequent elements](https://leetcode.com/problems/top-k-frequent-elements/description/) 31 | - [Rod Cutting](https://www.geeksforgeeks.org/problems/rod-cutting0840/1?utm_source=youtube&utm_medium=collab_striver_ytdescription&utm_campaign=rod-cutting) -------------------------------------------------------------------------------- /docs/extra/heap/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Heap", 3 | "position": 7, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "A Heap is a specialized tree-based data structure that satisfies the **Heap Property**. Heaps are commonly used to implement priority queues and ensure efficient retrieval of the minimum or maximum element." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/extra/heap/kth-smallest.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: Heap-data-Structure-3 3 | title: heap data structure 4 | sidebar_label: Kth smallest Element 5 | sidebar_position: 10 6 | description: Heaps are commonly used to implement priority queues and ensure efficient retrieval of the minimum or maximum element. 7 | tags: [Competitive Programming,top-K,priority queue] 8 | --- 9 | 10 | # Heap Problems: Kth Smallest Elements 11 | 12 | ## Problem : Kth Smallest Element in an Array 13 | 14 | ### Problem Description: 15 | Given an array of `n` integers, find the **Kth largest** element. The array may contain duplicate values, but you are tasked with identifying the Kth largest distinct element. 16 | 17 | ### Example: 18 | ``` 19 | Input: [3, 2, 1, 5, 6, 4], K = 2 20 | Output: 5 21 | ``` 22 | 23 | Approach: 24 | Using a Min Heap (Optimal Solution): 25 | Use a Min Heap to keep track of the top K largest elements. 26 | Iterate through the array, adding elements to the heap. 27 | If the heap size exceeds K, remove the smallest element from the heap. 28 | The top element of the heap will be the Kth largest when the iteration is complete. 29 | Time Complexity: O(n log K), where n is the number of elements in the array. 30 | 31 | ```cpp 32 | #include 33 | #include 34 | #include 35 | 36 | int findKthSmallest(std::vector& nums, int k) { 37 | std::priority_queue maxHeap; 38 | 39 | for (int num : nums) { 40 | maxHeap.push(num); // Add element to max heap 41 | 42 | if (maxHeap.size() > k) { 43 | maxHeap.pop(); // Remove the largest element if size exceeds k 44 | } 45 | } 46 | 47 | return maxHeap.top(); // The top of the heap is the Kth smallest element 48 | } 49 | 50 | int main() { 51 | std::vector nums = {7, 10, 4, 3, 20, 15}; 52 | int k = 3; 53 | std::cout << "The " << k << "th smallest element is " << findKthSmallest(nums, k) << std::endl; 54 | return 0; 55 | } 56 | ``` 57 | 58 | 59 | -------------------------------------------------------------------------------- /docs/extra/linked-list/CircularDoubly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/linked-list/CircularDoubly.png -------------------------------------------------------------------------------- /docs/extra/linked-list/CircularLinkedList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/linked-list/CircularLinkedList.png -------------------------------------------------------------------------------- /docs/extra/linked-list/DoublyLL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/linked-list/DoublyLL.png -------------------------------------------------------------------------------- /docs/extra/linked-list/LinkedList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/extra/linked-list/LinkedList.png -------------------------------------------------------------------------------- /docs/extra/linked-list/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Linked List", 3 | "position": 11, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn the most important concepts of Linked list." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: docs 3 | title: Welcome to Algo - Gateway to DSA Mastery! 4 | sidebar_label: Welcome to Algo 5 | sidebar_position: 1 6 | slug: / 7 | description: "Algo is your gateway to mastering Data Structures and Algorithms (DSA). Whether you're a coding enthusiast, a student, or a professional looking to enhance your programming skills, Algo is here to guide you through the intricate world of DSA." 8 | tags: [dsa, data structures, algorithms] 9 | --- 10 | 11 | Algo is your gateway to mastering Data Structures and Algorithms (DSA). Whether you're a coding enthusiast, a student, or a professional looking to enhance your programming skills, Algo is here to guide you through the intricate world of DSA. 12 | 13 | 14 | 15 | ## What Sets Algo Apart? 16 | 17 | ### Comprehensive Learning Pathways 18 | 19 | Algo provides carefully curated learning pathways designed to take you from a DSA novice to a proficient coder. Our structured approach ensures a smooth learning curve, starting with the basics and gradually progressing to advanced topics. 20 | 21 | ### Interactive Coding Challenges 22 | 23 | Learning by doing is at the heart of Algo. Engage in hands-on coding challenges that reinforce your understanding of key concepts. Our interactive platform allows you to apply what you've learned in a practical and engaging manner. 24 | 25 | 26 | 27 | ### Supportive Community 28 | 29 | Join a vibrant community of learners, mentors, and industry experts who are passionate about DSA. Collaborate, share knowledge, and grow together as you embark on your coding journey. 30 | 31 | ### Personalized Learning Experience 32 | 33 | Algo's adaptive learning platform tailors the content to your skill level and learning pace. Whether you're a beginner or an experienced coder, Algo provides a personalized learning experience that meets your unique needs. 34 | 35 | ## Get Started with Algo 36 | 37 | Ready to dive into the world of Data Structures and Algorithms? Start your learning journey with Algo today! Explore our learning pathways, tackle coding challenges, and connect with a community of like-minded individuals who share your passion for coding. 38 | 39 | --- 40 | 41 |

Feedback and Support

42 | 43 | -------------------------------------------------------------------------------- /docs/languages/SQL/sql-19.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: SQL-LIKE-Operator 3 | sidebar_position: 19 4 | title: "SQL LIKE Operator" 5 | sidebar_label: "SQL LIKE Operator" 6 | description: "The SQL LIKE operator is used to filter data based on patterns." 7 | tags: [sql, dbms, database, like] 8 | --- 9 | 10 | The `LIKE` operator is used in a `WHERE` clause to search for a specific pattern in a column. 11 | 12 | ### Syntax 13 | 14 | ```sql 15 | SELECT column_name(s) 16 | FROM table_name 17 | WHERE column_name LIKE pattern; 18 | ``` 19 | 20 | ### Pattern Matching 21 | 22 | You can use the following wildcard characters in the pattern: 23 | 24 | * **%**: Matches any character sequence, zero or more times. 25 | * **_**: Matches any single character. 26 | 27 | ### Examples 28 | 29 | **Example 1: Find all products that start with 'Ch'** 30 | 31 | ```sql 32 | SELECT * 33 | FROM Products 34 | WHERE ProductName LIKE 'Ch%'; 35 | ``` 36 | 37 | **Example 2: Find all products that contain 'an' anywhere in the name** 38 | 39 | ```sql 40 | SELECT * 41 | FROM Products 42 | WHERE ProductName LIKE '%an%'; 43 | ``` 44 | 45 | **Example 3: Find all products that end with 'syrup'** 46 | 47 | ```sql 48 | SELECT * 49 | FROM Products 50 | WHERE ProductName LIKE '%syrup'; 51 | ``` 52 | 53 | **Example 4: Find all products with a 4-character product ID starting with '1'** 54 | 55 | ```sql 56 | SELECT * 57 | FROM Products 58 | WHERE ProductID LIKE '1___'; 59 | ``` 60 | 61 | **Note:** The specific implementation and syntax might vary slightly depending on the database system you're using (e.g., MySQL, PostgreSQL, SQL Server). However, the core concept of using the `LIKE` operator with wildcard characters remains consistent. 62 | -------------------------------------------------------------------------------- /docs/languages/SQL/sql-20.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: SQL-Having-Clause 3 | sidebar_position: 20 4 | title: "SQL Having Clause" 5 | sidebar_label: "SQL Having Clause" 6 | description: "The `HAVING` clause in SQL is used to filter records in combination with the `GROUP BY` clause." 7 | tags: [sql, dbms, database, having] 8 | --- 9 | 10 | The `HAVING` clause is used in conjunction with the `GROUP BY` clause to filter the results of aggregated data. It allows you to specify conditions on groups created by the `GROUP BY` clause, enabling more advanced data filtering. 11 | 12 | ### Syntax 13 | 14 | ```sql 15 | SELECT column_name(s), aggregate_function(column_name) 16 | FROM table_name 17 | WHERE condition 18 | GROUP BY column_name(s) 19 | HAVING condition; 20 | ``` 21 | ### Key Points 22 | 23 | * The HAVING clause is similar to the WHERE clause, but it is applied to groups rather than individual rows. 24 | * You typically use HAVING to filter records after aggregation, making it suitable for conditions on aggregated data. 25 | 26 | ### Examples 27 | **Example 1: Find all categories with more than 10 products** 28 | 29 | ```sql 30 | SELECT CategoryID, COUNT(ProductID) AS ProductCount 31 | FROM Products 32 | GROUP BY CategoryID 33 | HAVING COUNT(ProductID) > 10; 34 | ``` 35 | 36 | **Example 2: Retrieve suppliers who have provided products worth more than $1,000** 37 | 38 | ```sql 39 | SELECT SupplierID, SUM(Price) AS TotalValue 40 | FROM Products 41 | GROUP BY SupplierID 42 | HAVING SUM(Price) > 1000; 43 | ``` 44 | 45 | **Example 3: List all customers with more than one order** 46 | 47 | ```sql 48 | SELECT CustomerID, COUNT(OrderID) AS OrderCount 49 | FROM Orders 50 | GROUP BY CustomerID 51 | HAVING COUNT(OrderID) > 1; 52 | ``` 53 | **Note**: 54 | The HAVING clause is often used with aggregate functions such as SUM(), COUNT(), AVG(), etc. It is important to note that the HAVING clause is evaluated after the GROUP BY clause, which means you cannot use it without grouping your results first. 55 | -------------------------------------------------------------------------------- /docs/languages/SQL/sql-21.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sql-group-by 3 | sidebar_position: 21 4 | title: "SQL GROUP BY Statement" 5 | sidebar_label: "SQL GROUP BY" 6 | description: "The SQL GROUP BY statement is used to group rows that have the same values in specified columns and apply aggregate functions." 7 | tags: [sql, dbms, database, group by] 8 | --- 9 | 10 | The `GROUP BY` statement in SQL is used to arrange identical data into groups. It is typically used with aggregate functions (such as `COUNT`, `SUM`, `AVG`, `MAX`, or `MIN`) to perform operations on each group. 11 | 12 | ### Syntax 13 | 14 | ```sql 15 | SELECT COUNT(CustomerID), Country 16 | FROM Customers 17 | GROUP BY Country 18 | HAVING COUNT(CustomerID) > 5; 19 | ``` 20 | 21 | ### Key Points 22 | 23 | * The GROUP BY statement groups rows that have the same values in specified columns. 24 | * It is often combined with aggregate functions to perform calculations on each group. 25 | * Using ORDER BY with GROUP BY allows you to sort the grouped results. 26 | 27 | ### Examples 28 | 29 | **Example 1: Count the number of products in each category** 30 | 31 | ```sql 32 | SELECT CategoryID, COUNT(ProductID) AS ProductCount 33 | FROM Products 34 | GROUP BY CategoryID; 35 | ``` 36 | 37 | **Example 2: Find the total sales for each salesperson** 38 | 39 | ```sql 40 | SELECT SalespersonID, SUM(SaleAmount) AS TotalSales 41 | FROM Sales 42 | GROUP BY SalespersonID; 43 | ``` 44 | 45 | **Example 3: Retrieve the average salary of employees in each department** 46 | 47 | ```sql 48 | SELECT DepartmentID, AVG(Salary) AS AverageSalary 49 | FROM Employees 50 | GROUP BY DepartmentID; 51 | ``` 52 | 53 | **Note:** 54 | * The GROUP BY clause must appear after the WHERE clause and before the ORDER BY clause if they are used together. 55 | * When using GROUP BY, only the grouped columns or aggregate functions can be included in the SELECT statement, as other columns would produce ambiguous results. 56 | * The HAVING clause can be used with GROUP BY to filter groups based on aggregate conditions. 57 | -------------------------------------------------------------------------------- /docs/languages/SQL/sql-22.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sql-select-top 3 | sidebar_position: 22 4 | title: "SQL SELECT TOP" 5 | sidebar_label: "SQL SELECT TOP" 6 | description: "The SQL SELECT TOP clause is used to limit the number of rows returned in a result set." 7 | tags: [sql, dbms, database, select top] 8 | --- 9 | 10 | The `SELECT TOP` clause is used in SQL to limit the number of rows returned in a query result. It is commonly used when you want to retrieve a specific number or percentage of records. 11 | 12 | ### Syntax 13 | 14 | In SQL Server: 15 | 16 | ```sql 17 | SELECT TOP number|percent column_name(s) 18 | FROM table_name 19 | WHERE condition; 20 | ``` 21 | In MySQL and PostgreSQL, you can use LIMIT instead: 22 | 23 | ```sql 24 | SELECT column_name(s) 25 | FROM table_name 26 | WHERE condition 27 | LIMIT number; 28 | ``` 29 | 30 | ### Key Points 31 | 32 | * The SELECT TOP clause is supported in SQL Server, while MySQL and PostgreSQL use the LIMIT clause instead. 33 | * You can specify either a fixed number or a percentage of rows to return. 34 | * This clause is especially useful for retrieving a subset of rows from large datasets, such as the top-performing items or recent entries. 35 | 36 | ### Examples 37 | 38 | **Example 1: Retrieve the top 5 most expensive products** 39 | 40 | ```sql 41 | SELECT TOP 5 ProductName, Price 42 | FROM Products 43 | ORDER BY Price DESC; 44 | ``` 45 | In MySQL/PostgreSQL, use: 46 | 47 | ```sql 48 | SELECT ProductName, Price 49 | FROM Products 50 | ORDER BY Price DESC 51 | LIMIT 5; 52 | ``` 53 | 54 | **Example 2: Retrieve the top 10% of employees with the highest salaries** 55 | 56 | ```sql 57 | SELECT TOP 10 PERCENT EmployeeName, Salary 58 | FROM Employees 59 | ORDER BY Salary DESC; 60 | ``` 61 | 62 | In MySQL/PostgreSQL, you would need to calculate the percentage manually, as they don’t support the PERCENT keyword in the same way. 63 | 64 | **Note:** 65 | The SELECT TOP clause is typically used with ORDER BY to control which records are selected based on specific criteria, such as descending order of price or date. Keep in mind that different SQL databases have variations in syntax for limiting rows. 66 | -------------------------------------------------------------------------------- /docs/languages/SQL/sql-23.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sql-alias 3 | sidebar_position: 23 4 | title: "SQL Alias" 5 | sidebar_label: "SQL Alias" 6 | description: "The SQL Alias is used to give a table or a column a temporary name." 7 | tags: [sql, dbms, database, alias] 8 | --- 9 | 10 | SQL aliases are temporary names assigned to tables or columns. They are primarily used to make column names more readable and to simplify queries, especially when working with multiple tables or complex calculations. 11 | 12 | ### Syntax 13 | 14 | For Column Alias: 15 | 16 | ```sql 17 | SELECT column_name AS alias_name 18 | FROM table_name; 19 | ``` 20 | 21 | For Table Alias: 22 | 23 | ```sql 24 | SELECT column_name(s) 25 | FROM table_name AS alias_name; 26 | ``` 27 | 28 | ### Key Points 29 | * Aliases are created using the AS keyword, although the keyword is optional in most databases. 30 | * Column aliases are useful for renaming columns in the result set. 31 | * Table aliases are helpful when dealing with complex queries, especially joins, where referencing the same table multiple times can make the query easier to read and write. 32 | 33 | ### Examples 34 | **Example 1: Assign an alias to a column** 35 | 36 | ```sql 37 | SELECT ProductName AS Product, Price AS Cost 38 | FROM Products; 39 | ``` 40 | In this example, ProductName is displayed as Product and Price as Cost in the result. 41 | 42 | **Example 2: Assign an alias to a table** 43 | 44 | ```sql 45 | SELECT p.ProductName, s.SupplierName 46 | FROM Products AS p 47 | INNER JOIN Suppliers AS s ON p.SupplierID = s.SupplierID; 48 | ``` 49 | Here, Products is aliased as p and Suppliers as s, making it easier to reference columns in the JOIN operation. 50 | 51 | **Example 3: Using aliases with calculations** 52 | 53 | ```sql 54 | SELECT Price, Price * 0.1 AS Tax 55 | FROM Products; 56 | ``` 57 | In this example, the calculated value Price * 0.1 is given the alias Tax for readability. 58 | 59 | **Note:** 60 | * Aliases exist only for the duration of the query; they do not change the actual column or table names in the database. 61 | * When using aliases, especially in complex queries or subqueries, it’s good practice to use clear, descriptive names to improve readability. 62 | -------------------------------------------------------------------------------- /docs/languages/SQL/sql-31.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sql-drop-database 3 | sidebar_position: 31 4 | title: "SQL DROP DATABASE Statement" 5 | sidebar_label: "SQL DROP DATABASE" 6 | description: "The SQL DROP DATABASE statement is used to delete an existing database." 7 | tags: [sql, dbms, database, drop database] 8 | --- 9 | 10 | The `DROP DATABASE` statement in SQL is used to delete an existing database, along with all its tables, data, and associated objects. This action is irreversible, so it should be used with caution. 11 | 12 | ### Syntax 13 | 14 | ```sql 15 | DROP DATABASE database_name; 16 | ``` 17 | 18 | ### Key Points 19 | * Permanent Deletion: The database and all its data are permanently deleted. 20 | * Permissions Required: Dropping a database generally requires administrative privileges. 21 | * Safety Precaution: Be certain before executing this command, as it cannot be undone. 22 | 23 | ### Example 24 | 25 | **Example 1: Basic DROP DATABASE Statement** 26 | 27 | Delete a database named StoreDB. 28 | 29 | ```sql 30 | DROP DATABASE StoreDB; 31 | ``` 32 | 33 | **Example 2: Conditionally Dropping a Database** 34 | 35 | To avoid errors when attempting to drop a database that may not exist, you can use a conditional check (supported in certain databases). 36 | 37 | ```sql 38 | DROP DATABASE IF EXISTS CustomerDB; 39 | ``` 40 | 41 | ### Viewing Available Databases 42 | 43 | Before deleting a database, you may want to view a list of existing databases to ensure accuracy: 44 | 45 | ```sql 46 | SHOW DATABASES; -- MySQL 47 | ``` 48 | 49 | Or, in SQL Server: 50 | 51 | ```sql 52 | SELECT name 53 | FROM sys.databases; 54 | ``` 55 | 56 | **Notes :** 57 | * Data Loss Warning: Dropping a database will delete all data and schema definitions within it. This action is irreversible. 58 | * Database Backup: It is recommended to create a backup of any critical data before using DROP DATABASE. 59 | * Compatibility: The DROP DATABASE statement is supported across most SQL systems, though syntax may vary slightly. 60 | 61 | The DROP DATABASE statement is a powerful command for removing databases when they are no longer needed, but it should be used with caution to prevent accidental data loss. 62 | -------------------------------------------------------------------------------- /docs/languages/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Languages", 3 | "position": 3, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "5 minutes to learn the most important RoadMap for Basic Concepts of programming." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/languages/cpp/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "C++", 3 | "position": 3, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "C++ is a compiled, high-level, general-purpose programming language. Developed by Bjarne Stroustrup and first released in 1985, C++ builds on C with object-oriented features, allowing for both low-level memory manipulation and high-level abstractions, making it suitable for a wide range of applications." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/languages/csharp/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "C#", 3 | "position": 4, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "C# is a modern, high-level programming language developed by Microsoft as part of the .NET framework. First released in 2002, C# is known for its strong typing, garbage collection, and support for object-oriented programming, making it popular for a variety of applications including web, desktop, and mobile development. With cross-platform support through .NET Core, C# allows developers to create versatile and performant software solutions across different environments." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/languages/java/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Java", 3 | "position": 5, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/languages/javascript/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "JavaScript", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "JavaScript is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/languages/python/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Python", 3 | "position": 3, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code readability with its notable use of significant whitespace." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/programming-fundamentals/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Programming Fundamentals", 3 | "position": 4, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Programming Fundamentals. This is the first step to become a good programmer." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Control Structures", 3 | "position": 2, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Programming Fundamentals. This is the first step to become a good programmer." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/break.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/break.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/continue.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/continue.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/do-while-loop.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/do-while-loop.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/finally.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/finally.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/return.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/return.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/throw.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/throw.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/try-catch.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/try-catch.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/control-structures/while-loop.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/control-structures/while-loop.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Functions", 3 | "position": 3, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Programming Fundamentals. This is the first step to become a good programmer." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-call.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-call.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-closures.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-closures.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-composition.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-composition.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-currying.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-currying.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-declaration.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-declaration.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-memoization.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-memoization.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-overloading.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-overloading.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-parameters.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-parameters.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-recursion.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-recursion.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-return.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-return.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/functions/function-scope.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/functions/function-scope.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/language-syntax/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Language Syntax", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Programming Fundamentals. This is the first step to become a good programmer." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/programming-fundamentals/language-syntax/inheritance.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: inheritance 3 | sidebar_position: 10 4 | title: Inheritance 5 | sidebar_label: Inheritance 6 | description: Learn about inheritance in JavaScript, Java, Python, and C++. 7 | tags: [inheritance, programming, syntax, js, java, python, cpp] 8 | keywords: [inheritance, programming, classes, instances, data, methods, properties] 9 | --- -------------------------------------------------------------------------------- /docs/programming-fundamentals/language-syntax/interfaces.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/language-syntax/interfaces.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/language-syntax/polymorphism.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/language-syntax/polymorphism.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "OOP Basic", 3 | "position": 4, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn about Programming Fundamentals. This is the first step to become a good programmer." 7 | } 8 | } -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/abstract-classes.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/abstract-classes.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/abstraction.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/abstraction.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/classes.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/classes.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/composition.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/composition.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/delegation.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/delegation.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/encapsulation.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/encapsulation.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/inheritance.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/inheritance.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/interfaces.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/interfaces.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/mixins.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/mixins.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/objects.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/objects.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/oop-basics/polymorphism.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/oop-basics/polymorphism.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/Introduction.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/Introduction.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/arrays.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/arrays.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/classes.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/classes.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/conditionals.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/conditionals.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/functions.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/functions.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/inheritance.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/inheritance.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/loops.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/loops.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/objects.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/objects.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/operators.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/operators.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/polymorphism.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/polymorphism.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/strings.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/strings.md -------------------------------------------------------------------------------- /docs/programming-fundamentals/pseudo-code/variables.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/docs/programming-fundamentals/pseudo-code/variables.md -------------------------------------------------------------------------------- /dsa-interview-sidebars.js: -------------------------------------------------------------------------------- 1 | 2 | // @ts-check 3 | 4 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 5 | const sidebarsDSAInterview = { 6 | // By default, Docusaurus generates a sidebar from the docs folder structure 7 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], 8 | 9 | }; 10 | 11 | export default sidebarsDSAInterview; 12 | -------------------------------------------------------------------------------- /festhack.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/festhack.jpg -------------------------------------------------------------------------------- /girlscript.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/girlscript.jpg -------------------------------------------------------------------------------- /learn.md: -------------------------------------------------------------------------------- 1 | # Learn with Algo 2 | 3 | Algo is a comprehensive algorithm repository designed to help developers improve their problem-solving skills. Here's how you can get started and learn from this project: 4 | 5 | ## Topics Covered 6 | - Sorting Algorithms 7 | - Searching Algorithms 8 | - Dynamic Programming 9 | - Greedy Algorithms 10 | - Graph Algorithms 11 | - Data Structures 12 | 13 | ## How to Use This Repository 14 | 1. Clone the repository to your local machine. 15 | 2. Browse through the folders to find algorithms categorized by topics. 16 | 3. Each algorithm includes: 17 | - A detailed description of the problem 18 | - The solution code 19 | - Time and space complexity analysis 20 | 21 | ## Learning Resources 22 | - We recommend starting with **Sorting Algorithms** if you're new to algorithms. 23 | - Each algorithm file is documented with comments and explanations to help you understand the logic and steps involved. 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "algo", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "gh-pages -d build", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids" 15 | }, 16 | "dependencies": { 17 | "@docusaurus/core": "^3.5.2", 18 | "@docusaurus/plugin-content-blog": "^3.5.2", 19 | "@docusaurus/plugin-content-docs": "^3.5.2", 20 | "@docusaurus/plugin-debug": "^3.5.2", 21 | "@docusaurus/preset-classic": "^3.5.2", 22 | "@docusaurus/theme-mermaid": "^3.5.2", 23 | "@docusaurus/theme-search-algolia": "^3.5.2", 24 | "@fortawesome/free-brands-svg-icons": "^6.6.0", 25 | "@fortawesome/react-fontawesome": "^0.2.2", 26 | "@giscus/react": "^3.0.0", 27 | "@heroicons/react": "^2.1.5", 28 | "@mdx-js/react": "^3.0.0", 29 | "axios": "^1.7.7", 30 | "clsx": "^2.0.0", 31 | "framer-motion": "^11.9.0", 32 | "joi": "^17.13.3", 33 | "mermaid": "^11.0.0", 34 | "prism-react-renderer": "^2.1.0", 35 | "react": "^18.0.0", 36 | "react-dom": "^18.0.0", 37 | "react-icons": "^5.3.0", 38 | "react-lite-youtube-embed": "^2.4.0", 39 | "react-simple-chatbot": "^0.6.0", 40 | "react-toastify": "^10.0.5", 41 | "rehype-katex": "^7.0.1", 42 | "remark-math": "^6.0.0", 43 | "styled-components": "^4.4.1", 44 | "swiper": "^11.1.14" 45 | }, 46 | "devDependencies": { 47 | "@docusaurus/module-type-aliases": "3.5.2", 48 | "@docusaurus/types": "3.5.2", 49 | "autoprefixer": "^10.4.20", 50 | "gh-pages": "^6.1.0", 51 | "postcss": "^8.4.47", 52 | "tailwindcss": "^3.4.13" 53 | }, 54 | "browserslist": { 55 | "production": [ 56 | ">0.5%", 57 | "not dead", 58 | "not op_mini all" 59 | ], 60 | "development": [ 61 | "last 3 chrome version", 62 | "last 3 firefox version", 63 | "last 5 safari version" 64 | ] 65 | }, 66 | "engines": { 67 | "node": ">=18.0" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /plugins/my-plugin/index.js: -------------------------------------------------------------------------------- 1 | const Joi = require("joi"); 2 | 3 | module.exports = function (context, options) { 4 | return { 5 | name: "my-plugin", 6 | // lifecycle methods 7 | injectHtmlTags() { 8 | return { 9 | headTags: [ 10 | { 11 | tagName: "meta", 12 | attributes: { 13 | "og:description": "My custom OG: Description", 14 | }, 15 | }, 16 | ], 17 | }; 18 | }, 19 | extendCli(cli) { 20 | cli 21 | .command("my-command action") 22 | .description("This is a custom command") 23 | .action(() => { 24 | console.log("Hello World! - This is a custom command!"); 25 | console.log("Plugin options:", options); 26 | }); 27 | }, 28 | configurePostCss(postcssOptions) { 29 | // Add Tailwind CSS and other PostCSS plugins 30 | postcssOptions.plugins = [ 31 | require("postcss-import"), 32 | require("tailwindcss"), 33 | require("autoprefixer"), 34 | ]; 35 | return postcssOptions; 36 | }, 37 | }; 38 | }; 39 | 40 | module.exports.validateOptions = ({ validate, options }) => { 41 | const joiSchema = Joi.object({ 42 | settings: Joi.string().alphanum().min(3).max(30).required(), 43 | api: Joi.string().required(), 44 | keys: Joi.string().min(2).required(), 45 | }); 46 | 47 | const validateOptions = validate(joiSchema, options); 48 | 49 | return validateOptions; 50 | }; -------------------------------------------------------------------------------- /postman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajay-dhangar/algo/a7b6d68d045fe682b5c1d30c0f4dd20ad2955fa9/postman.png -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | "config:recommended", 5 | ":dependencyDashboard" 6 | ], 7 | "schedule": [ 8 | "at any time" 9 | ], 10 | "packageRules": [ 11 | { 12 | "packagePatterns": ["*"], 13 | "groupName": "all dependencies", 14 | "groupSlug": "all" 15 | } 16 | ], 17 | "automerge": false, 18 | "automergeType": "pr", 19 | "prHourlyLimit": 24, 20 | "prConcurrentLimit": 10, 21 | "labels": ["dependencies"], 22 | "reviewers": ["Ajay-Dhangar"] 23 | } -------------------------------------------------------------------------------- /sidebars.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creating a sidebar enables you to: 3 | - create an ordered group of docs 4 | - render a sidebar for each doc of that group 5 | - provide next/previous navigation 6 | 7 | The sidebars can be generated from the filesystem, or explicitly defined here. 8 | 9 | Create as many sidebars as you want. 10 | */ 11 | 12 | // @ts-check 13 | 14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 15 | const sidebars = { 16 | // By default, Docusaurus generates a sidebar from the docs folder structure 17 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], 18 | 19 | // But you can create a sidebar manually 20 | /* 21 | tutorialSidebar: [ 22 | 'intro', 23 | 'hello', 24 | { 25 | type: 'category', 26 | label: 'Tutorial', 27 | items: ['tutorial-basics/create-a-document'], 28 | }, 29 | ], 30 | */ 31 | }; 32 | 33 | export default sidebars; 34 | -------------------------------------------------------------------------------- /src/components/AdsComponent/Ads.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import Head from "@docusaurus/Head"; 3 | 4 | declare global { 5 | interface Window { 6 | adsbygoogle: any[]; 7 | } 8 | } 9 | 10 | const Ads: React.FC = () => { 11 | useEffect(() => { 12 | try { 13 | (window.adsbygoogle = window.adsbygoogle || []).push({}); 14 | } 15 | catch (err) { 16 | console.error(err); 17 | } 18 | }, []); 19 | return ( 20 | <> 21 | 22 | 52 | 53 |
54 | 55 | 56 | 57 | 58 |
59 | 60 | ); 61 | } 62 | -------------------------------------------------------------------------------- /src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /src/pages/quiz-solutions/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Layout from "@theme/Layout"; 3 | import Header from "../../components/Header"; 4 | import QuizCard from "../../components/QuizCard"; 5 | import quizData from "../../data/quizData"; 6 | 7 | const Quizes: React.FC = () => ( 8 | 12 |
13 |
17 |
18 | {quizData.map((quiz, index) => ( 19 | 25 | ))} 26 |
27 |
28 |
29 | ); 30 | 31 | export default Quizes; 32 | -------------------------------------------------------------------------------- /src/theme/Admonition/Icon/Danger.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Danger from '@theme-original/Admonition/Icon/Danger'; 3 | 4 | export default function DangerWrapper(props) { 5 | return ( 6 | <> 7 | 8 | 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /src/theme/Admonition/Layout/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Layout from '@theme-original/Admonition/Layout'; 3 | 4 | export default function LayoutWrapper(props) { 5 | return ( 6 | <> 7 | 8 | 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /src/theme/CodeBlock/Line/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import clsx from 'clsx'; 3 | import styles from './styles.module.css'; 4 | export default function CodeBlockLine({ 5 | line, 6 | classNames, 7 | showLineNumbers, 8 | getLineProps, 9 | getTokenProps, 10 | }) { 11 | if (line.length === 1 && line[0].content === '\n') { 12 | line[0].content = ''; 13 | } 14 | const lineProps = getLineProps({ 15 | line, 16 | className: clsx(classNames, showLineNumbers && styles.codeLine), 17 | }); 18 | const lineTokens = line.map((token, key) => ( 19 | 20 | )); 21 | return ( 22 | 23 | {showLineNumbers ? ( 24 | <> 25 | 26 | {lineTokens} 27 | 28 | ) : ( 29 | lineTokens 30 | )} 31 |
32 |
33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /src/theme/CodeBlock/Line/styles.module.css: -------------------------------------------------------------------------------- 1 | /* Intentionally has zero specificity, so that to be able to override 2 | the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */ 3 | :where(:root) { 4 | --docusaurus-highlighted-code-line-bg: rgb(72 77 91); 5 | } 6 | 7 | :where([data-theme='dark']) { 8 | --docusaurus-highlighted-code-line-bg: rgb(100 100 100); 9 | } 10 | 11 | :global(.theme-code-block-highlighted-line) { 12 | background-color: var(--docusaurus-highlighted-code-line-bg); 13 | display: block; 14 | margin: 0 calc(-1 * var(--ifm-pre-padding)); 15 | padding: 0 var(--ifm-pre-padding); 16 | } 17 | 18 | .codeLine { 19 | display: table-row; 20 | counter-increment: line-count; 21 | } 22 | 23 | .codeLineNumber { 24 | display: table-cell; 25 | text-align: right; 26 | width: 1%; 27 | position: sticky; 28 | left: 0; 29 | padding: 0 var(--ifm-pre-padding); 30 | background: var(--ifm-pre-background); 31 | overflow-wrap: normal; 32 | } 33 | 34 | .codeLineNumber::before { 35 | content: counter(line-count); 36 | opacity: 0.4; 37 | } 38 | 39 | :global(.theme-code-block-highlighted-line) .codeLineNumber::before { 40 | opacity: 0.8; 41 | } 42 | 43 | .codeLineContent { 44 | padding-right: var(--ifm-pre-padding); 45 | } 46 | -------------------------------------------------------------------------------- /src/theme/MDXComponents.js: -------------------------------------------------------------------------------- 1 | import "react-lite-youtube-embed/dist/LiteYouTubeEmbed.css"; 2 | import AdsComponent from "@site/src/components/AdsComponent"; 3 | // import BrowserWindow from "@site/src/components/BrowserWindow"; 4 | import ArrayVisualizations from "@site/src/components/DSA/arrays/ArrayVisualizations"; 5 | import BubbleSortVisualization from "@site/src/components/DSA/arrays/BubbleSortVisualization"; 6 | import InsertionSortVisualization from "@site/src/components/DSA/arrays/InsertionSortVisualization"; 7 | import QuickSortVisualization from "@site/src/components/DSA/arrays/QuickSortVisualization"; 8 | import HeapSortVisualization from "@site/src/components/DSA/arrays/HeapSortVisualization"; 9 | import SelectionSortVisualization from "@site/src/components/DSA/arrays/SelectionSortVisualization"; 10 | import DijkstraVisuzalizations from "@site/src/components/DSA/graphs/DijkstraVisualizations"; 11 | import FloydWarshallVisualizations from "@site/src/components/DSA/graphs/FloydWarshallVisualizations"; 12 | import Highlight from "@site/src/components/Highlight"; 13 | import MDXComponents from "@theme-original/MDXComponents"; 14 | // import Image from "@theme/IdealImage"; 15 | import TabItem from "@theme/TabItem"; 16 | import Tabs from "@theme/Tabs"; 17 | import { FaReact } from "react-icons/fa"; 18 | import LiteYouTubeEmbed from "react-lite-youtube-embed"; 19 | import GiscusComponent from "../components/GiscusComponent"; 20 | import Ads from "@site/src/components/AdsComponent/Ads"; 21 | 22 | export default { 23 | // Re-use the default mapping 24 | ...MDXComponents, 25 | // custom 26 | Tabs, 27 | TabItem, 28 | Highlight, 29 | ArrayVisualizations, 30 | BubbleSortVisualization, 31 | SelectionSortVisualization, 32 | FaReact, 33 | DijkstraVisuzalizations, 34 | FloydWarshallVisualizations, 35 | InsertionSortVisualization, 36 | QuickSortVisualization, 37 | HeapSortVisualization, 38 | // Image, 39 | LiteYouTubeEmbed, 40 | // LinearSearchVisualizer, 41 | AdsComponent, 42 | GiscusComponent, 43 | Ads, 44 | }; 45 | -------------------------------------------------------------------------------- /src/theme/Mermaid/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Mermaid from '@theme-original/Mermaid'; 3 | 4 | export default function MermaidWrapper(props) { 5 | return ( 6 | <> 7 | 8 | 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /src/theme/ReactLiveScope/components.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export const ButtonExample = (props) => ( 4 |