{"id":21973721,"url":"https://github.com/minaminao/algorithms","last_synced_at":"2025-04-28T14:44:09.775Z","repository":{"id":52279151,"uuid":"172819078","full_name":"minaminao/algorithms","owner":"minaminao","description":"Algorithms and data structures in C++/Rust/Python/JavaScript/Go.","archived":false,"fork":false,"pushed_at":"2022-11-04T11:08:11.000Z","size":185,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T04:54:05.373Z","etag":null,"topics":["algorithms","data-structures","quantum-algorithms"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minaminao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-27T01:23:15.000Z","updated_at":"2022-08-05T06:40:06.000Z","dependencies_parsed_at":"2023-01-21T22:03:29.302Z","dependency_job_id":null,"html_url":"https://github.com/minaminao/algorithms","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minaminao%2Falgorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minaminao%2Falgorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minaminao%2Falgorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minaminao%2Falgorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minaminao","download_url":"https://codeload.github.com/minaminao/algorithms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251332254,"owners_count":21572579,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","data-structures","quantum-algorithms"],"created_at":"2024-11-29T15:34:30.199Z","updated_at":"2025-04-28T14:44:09.755Z","avatar_url":"https://github.com/minaminao.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Algorithms and Data Structures\nImplementations of algorithms and data structures, code snippets, etc. These algorithms and data structures can be used for everyday programming and competitive programming.\nThe implementation of the algorithms in Rust language has been moved to [minaminao/algo-rs](https://github.com/minaminao/algo-rs).\n\nIf you getting the message \"Sorry, something went wrong. Reload?\" when viewing a Jupyter notebook, try to see [nbviewer](https://nbviewer.jupyter.org/github/minaminao/algorithms/tree/master/).\n\n## Combinatorics\n| Algorithm                     | Implementation                                       | Note |\n| ----------------------------- | ---------------------------------------------------- | ---- |\n| Combinatorics                 | [C++](Combinatorics/Combinatorics.cpp)               |      |\n| Factorial                     | [C++](Combinatorics/Factorial.cpp)                   |      |\n| Inclusion–Exclusion Principle | [C++](Combinatorics/InclusionExclusionPrinciple.cpp) |      |\n| Montmort Numbers              | [C++](Combinatorics/MontmortNumbers.cpp)             |      |\n| Number of Subsequences        | [C++](Combinatorics/NumberOfSubsequences.cpp)        |      |\n| Partition Numbers             | [C++](Combinatorics/PartitionNumbers.cpp)            |      |\n| Stirling Numbers              | [C++](Combinatorics/StirlingNumbers.cpp)             |      |\n\n## Cryptography \n*These implementations are not secure.*\n\n| Algorithm | Implementation                    | Note |\n| --------- | --------------------------------- | ---- |\n| ElGamal   | [C++](Cryptography/ElGamal.ipynb) |      |\n| RSA       | [C++](Cryptography/RSA.ipynb)     |      |\n\n## Data Structures \n| Algorithm                   | Implementation                                                                                                  | Note |\n| --------------------------- | --------------------------------------------------------------------------------------------------------------- | ---- |\n| Segment Tree                |                                                                                                                 |      |\n| - Range Add Query           | [C++](DataStructures/SegmentTree/RangeAddQuery.cpp)                                                             |      |\n| - Range Minimum Query       | [C++](DataStructures/SegmentTree/RangeMinimumQuery.cpp)                                                         |      |\n| - Range Update Query        | [C++](DataStructures/SegmentTree/RangeUpdateQuery.cpp)                                                          |      |\n| Square Root Decomposition   |                                                                                                                 |      |\n| - Range Add Query           | [C++](DataStructures/SquareRootDecomposition/RangeAddQuery.cpp)                                                 |      |\n| - Range Minimum Query       | [C++](DataStructures/SquareRootDecomposition/RangeAddQuery.cpp)                                                 |      |\n| - Range Sum Query           | [C++](DataStructures/SquareRootDecomposition/RangeSumQuery.cpp)                                                 |      |\n| - Range Update Query        | [C++](DataStructures/SquareRootDecomposition/RangeUpdateQuery.cpp)                                              |      |\n| - RMQ and RUQ               | [C++](DataStructures/SquareRootDecomposition/RMQandRUQ.cpp)                                                     |      |\n| - RSQ and RAQ               | [C++](DataStructures/SquareRootDecomposition/RSQandRAQ.cpp)                                                     |      |\n| - Square Root Decomposition | [C++](DataStructures/SquareRootDecomposition/SquareRootDecomposition.cpp)                                       |      |\n| Binary Heap                 | [C++](DataStructures/BinaryHeap.cpp)                                                                            |      |\n| Binary Indexed Tree         | [C++](DataStructures/BinaryIndexedTree.cpp), [Rust](DataStructures/BinaryIndexedTree.rs)                        |      |\n| Compression                 | [C++](DataStructures/Compression.cpp)                                                                           |      |\n| k-d Tree                    | [C++](DataStructures/KdTree.cpp)                                                                                |      |\n| Leftist Heap                | [C++](DataStructures/LeftistHeap.cpp)                                                                           |      |\n| Sparse Table                | [C++](DataStructures/SparseTable.cpp)                                                                           |      |\n| Treap                       | [C++](DataStructures/Treap.cpp)                                                                                 |      |\n| Union–Find                  | [C++](DataStructures/UnionFind.cpp), [Rust](DataStructures/UnionFind.rs), [Python](DataStructures/UnionFind.py) |      |\n\n## Dynamic Optimization\n| Algorithm                      | Implementation                                              | Note |\n| ------------------------------ | ----------------------------------------------------------- | ---- |\n| Digit DP                       | [C++](DynamicOptimization/DigitDP.cpp)                      |      |\n| Dynamic Optimization           | [C++](DynamicOptimization/DynamicOptimization.cpp)          |      |\n| Game Theory                    | [C++](DynamicOptimization/GameTheory.cpp)                   |      |\n| Largest Rectangle              | [C++](DynamicOptimization/LargestRectangle.cpp)             |      |\n| Largest Square                 | [C++](DynamicOptimization/LargestSquare.cpp)                |      |\n| Longest Increasing Subsequence | [C++](DynamicOptimization/LongestIncreasingSubsequence.cpp) |      |\n| Matrix Chain Multiplication    | [C++](DynamicOptimization/MatrixChainMultiplication.cpp)    |      |\n| Traveling Salesman Problem     | [C++](DynamicOptimization/TravelingSalesmanProblem.cpp)     |      |\n\n## Geometry\n| Algorithm                    | Implementation                                 | Note |\n| ---------------------------- | ---------------------------------------------- | ---- |\n| Bounding Sphere              | [C++](Geometry/BoundingSphere.cpp)             |      |\n| Geometry                     | [C++](Geometry/Geometry.cpp)                   |      |\n| Geometry 3D                  | [C++](Geometry/Geometry3D.cpp)                 |      |\n| Minimum-Weight Triangulation | [C++](Geometry/MinimumWeightTriangulation.cpp) |      |\n\n## Graph Theory \n| Algorithm                              | Implementation                                                     | Note |\n| -------------------------------------- | ------------------------------------------------------------------ | ---- |\n| Matching                               |                                                                    |      |\n| - Bipartite Matching                   | [C++](GraphTheory/Matching/BipartiteMatching.cpp)                  |      |\n| - Hopcroft–Karp Algorithm              | [C++](GraphTheory/Matching/HopcroftKarp.cpp)                       |      |\n| - Lexicographically Bipartite Matching | [C++](GraphTheory/Matching/LexicographicallyBipartiteMatching.cpp) |      |\n| - Stable Matching                      | [C++](GraphTheory/Matching/StableMatching.cpp)                     |      |\n| Shortest Path                          |                                                                    |      |\n| - 0-1 BFS                              | [C++](GraphTheory/ShortestPath/0-1BFS.cpp)                         |      |\n| - All Pairs Shortest Paths             | [C++](GraphTheory/ShortestPath/AllPairsShortestPaths.cpp)          |      |\n| - BFS                                  | [C++](GraphTheory/ShortestPath/BFS.cpp)                            |      |\n| - Bellman–Ford Algorithm               | [C++](GraphTheory/ShortestPath/BellmanFord.cpp)                    |      |\n| - Build DAG                            | [C++](GraphTheory/ShortestPath/BuilldDAG.cpp)                      |      |\n| - Dijkstra's Algorithm                 | [C++](GraphTheory/ShortestPath/Dijkstra.cpp)                       |      |\n| - Get Path                             | [C++](GraphTheory/ShortestPath/GetPath.cpp)                        |      |\n| Tree                                   |                                                                    |      |\n| - Lowest Common Ancestors              | [C++](GraphTheory/Tree/LowestCommonAncestors.cpp)                  |      |\n| - Tree                                 | [C++](GraphTheory/Tree/Tree.cpp)                                   |      |\n| All Pairs Widest Paths                 | [C++](GraphTheory/AllPairsWidestPaths.cpp)                         |      |\n| BFS                                    | [C++](GraphTheory/BFS.cpp)                                         |      |\n| Bipartite Graph                        | [C++](GraphTheory/BipartiteGraph.cpp)                              |      |\n| Chromatic Polynomial                   | [C++](GraphTheory/ChromaticPolynomial.cpp)                         |      |\n| Cycle Detection                        | [C++](GraphTheory/CycleDetection.cpp)                              |      |\n| Diameter                               | [C++](GraphTheory/Diameter.cpp)                                    |      |\n| DFS                                    | [C++](GraphTheory/DFS.cpp)                                         |      |\n| Eulerian Path                          | [C++](GraphTheory/EulerianPath.cpp)                                |      |\n| Graph                                  | [C++](GraphTheory/Graph.cpp)                                       |      |\n| Low-link                               | [C++](GraphTheory/LowLink.cpp)                                     |      |\n| Minimum Spanning Arborescence          | [C++](GraphTheory/MinimumSpanningArborescence.cpp)                 |      |\n| Minimum Spanning Tree                  | [C++](GraphTheory/MinimumSpanningTree.cpp)                         |      |\n| Strongly Connected Components          | [C++](GraphTheory/StronglyConnectedComponents.cpp)                 |      |\n| Topological Sort                       | [C++](GraphTheory/TopologicalSort.cpp)                             |      |\n\n## Greedy \n| Algorithm                  | Implementation                             | Note |\n| -------------------------- | ------------------------------------------ | ---- |\n| Activity Selection Problem | [C++](Greedy/ActivitySelectionProblem.cpp) |      |\n\n## Linear Algebra \n| Algorithm                        | Implementation                               | Note |\n| -------------------------------- | -------------------------------------------- | ---- |\n| Gauss Elimination                | [C++](LinearAlgebra/GaussElimination.cpp)    |      |\n| Gauss Elimination Modulo A Prime | [C++](LinearAlgebra/GaussEliminationMod.cpp) |      |\n| Gram–Schmidt Process             | [C++](LinearAlgebra/GramSchmidtProcess.cpp)  |      |\n| Matrix                           | [C++](LinearAlgebra/Matrix.cpp)              |      |\n\n## Machine Learning \n| Algorithm     | Implementation                         | Note |\n| ------------- | -------------------------------------- | ---- |\n| Least Squares | [C++](MachineLearning/LeastSquares.py) |      |\n\n## Number Theory \n| Algorithm                                | Implementation                                                                                              | Note |\n| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ---- |\n| Bernoulli Numbers                        | [C++](NumberTheory/BernoulliNumbers.cpp)                                                                    |      |\n| Binomial Coefficient                     | [C++](NumberTheory/BinomialCoefficient.cpp)                                                                 |      |\n| Chinese Remainder Theorem                | [C++](NumberTheory/ChineseRemainderTheorem.cpp), [Python](NumberTheory/ChineseRemainderTheorem.py)          |      |\n| Divisors                                 | [C++](NumberTheory/Divisors.cpp)                                                                            |      |\n| Extended Euclidean Algorithm             | [C++](NumberTheory/ExtendedGCD_Inverse.cpp), [Python](NumberTheory/ExtendedGCD.py)                          |      |\n| Euler's Totient Function                 | [C++](NumberTheory/EulerTotientFunction.cpp)                                                                |      |\n| GCD, LCM                                 | [C++](NumberTheory/ExtendedGCD_Inverse.cpp), [Go](NumberTheory/GCD_LCM.go), [Rust](NumberTheory/GCD_LCM.rs) |      |\n| Inverse Element                          | [C++](NumberTheory/ExtendedGCD_Inverse.cpp), [Python](NumberTheory/Inverse.py)                              |      |\n| Legendre's Formula                       | [C++](NumberTheory/LegendreFormula.cpp)                                                                     |      |\n| Log Factorial (Stirling's Approximation) | [C++](NumberTheory/LogFactorial.cpp)                                                                        |      |\n| ModInt                                   | [C++](NumberTheory/ModInt.cpp)                                                                              |      |\n| Modular Arithmetic                       | [C++](NumberTheory/ModularArithmetic.cpp)                                                                   |      |\n| Number Theory                            | [C++](NumberTheory/NumberTheory.cpp)                                                                        |      |\n| Polynomial                               | [C++](NumberTheory/Polynomial.cpp)                                                                          |      |\n| Primality Test                           | [C++](NumberTheory/PrimalityTest.cpp)                                                                       |      |\n| Prime                                    | [C++](NumberTheory/Prime.cpp)                                                                               |      |\n| Prime Factorization                      | [C++](NumberTheory/PrimeFactorization.cpp)                                                                  |      |\n| Quadratic Residue                        | [C++](NumberTheory/QuadraticResidue.cpp)                                                                    |      |\n| Radix                                    | [C++](NumberTheory/Radix.cpp)                                                                               |      |\n| Sum Of Powers                            | [C++](NumberTheory/SumOfPowers.cpp)                                                                         |      |\n\n## Numerical Analysis\n| Algorithm              | Implementation                                     | Note |\n| ---------------------- | -------------------------------------------------- | ---- |\n| Bisection Method       | [C++](NumericalAnalysis/BisectionMethod.cpp)       |      |\n| Cubic Equation         | [C++](NumericalAnalysis/CubicEquation.cpp)         |      |\n| Lagrange Interpolation | [C++](NumericalAnalysis/LagrangeInterpolation.cpp) |      |\n| Numerical Analysis     | [C++](NumericalAnalysis/NumericalAnalysis.cpp)     |      |\n| Quadratic Equation     | [C++](NumericalAnalysis/QuadraticEquation.cpp)     |      |\n\n## Quantum \n| Algorithm                    | Implementation                            | Note |\n| ---------------------------- | ----------------------------------------- | ---- |\n| Adder                        | [C++](Quantum/Adder.ipynb)                |      |\n| Bell State                   | [C++](Quantum/BellState.ipynb)            |      |\n| Bernstein–Vazirani Algorithm | [C++](Quantum/BernsteinVazirani.ipynb)    |      |\n| Deutsch's Algorithm          | [C++](Quantum/Deutsch.ipynb)              |      |\n| Deutsch–Jozsa Algorithm      | [C++](Quantum/DeutschJozsa.ipynb)         |      |\n| Entanglement                 | [C++](Quantum/Entanglement.ipynb)         |      |\n| GHZ State                    | [C++](Quantum/GHZState.ipynb)             |      |\n| n-CNOT                       | [C++](Quantum/n-CNOT.ipynb)               |      |\n| Oracle                       | [C++](Quantum/Oracle.ipynb)               |      |\n| Plus State, Minus State      | [C++](Quantum/PlusState_MinusState.ipynb) |      |\n| Simon's Algorithm            | [C++](Quantum/Simon.ipynb)                |      |\n\n## Signal Processing\n| Algorithm              | Implementation                                   | Note |\n| ---------------------- | ------------------------------------------------ | ---- |\n| Fast Fourier Transform | [C++](SignalProcessing/FastFourierTransform.cpp) |      |\n\n## Sort\n| Algorithm                | Implementation                       | Note |\n| ------------------------ | ------------------------------------ | ---- |\n| Bubble Sort              | [C++](Sort/BubbleSort.cpp)           |      |\n| Counting Sort            | [C++](Sort/CountingSort.cpp)         |      |\n| Insertion Sort           | [C++](Sort/InsertionSort.cpp)        |      |\n| Inversion Number         | [C++](Sort/InversionNumber.cpp)      |      |\n| Merge Sort               | [C++](Sort/MergeSort.cpp)            |      |\n| Minimum Cost Sort        | [C++](Sort/MinimumCostSort.cpp)      |      |\n| Minimum Numbers Of Swaps | [C++](Sort/MinimumNumbersOfSwap.cpp) |      |\n| Quick Sort               | [C++](Sort/QuickSort.cpp)            |      |\n| Sort                     | [C++](Sort/Sort.cpp)                 |      |\n\n## String \n| Algorithm              | Implementation                                           | Note |\n| ---------------------- | -------------------------------------------------------- | ---- |\n| Distance               | [C++](String/Distance.cpp), [Python](String/Distance.py) |      |\n| Fill                   | [C++](String/Fill.cpp)                                   |      |\n| Manacher's Algorithm   | [C++](String/Manacher.cpp)                               |      |\n| Morris–Pratt Algorithm | [C++](String/MorrisPratt.cpp)                            |      |\n| Parser                 | [C++](String/Parser.cpp)                                 |      |\n| Replace                | [C++](String/Replace.cpp)                                |      |\n| Rolling Hash           | [C++](String/RollingHash.cpp)                            |      |\n| Split, Join            | [C++](String/Split_Join.cpp)                             |      |\n| Suffix Array           | [C++](String/SuffixArray.cpp)                            |      |\n| Z Algorithm            | [C++](String/ZAlgorithm.cpp)                             |      |\n\n## Others\n| Algorithm           | Implementation                                                   | Note |\n| ------------------- | ---------------------------------------------------------------- | ---- |\n| Binary Search       | [C++](Others/BinarySearch.cpp), [Python](Others/BinarySearch.py) |      |\n| Gray Code           | [C++](Others/GrayCode.py)                                        |      |\n| Interactive Problem | [C++](Others/InteractiveProblem.cpp)                             |      |\n| Normal Distribution | [C++](Others/NormalDistribution.js)                              |      |\n| Number To String    | [C++](Others/NumberToString.py)                                  |      |\n| Number To Words     | [C++](Others/NumberToWords.py)                                   |      |\n| Others              | [C++](Others/Others.cpp)                                         |      |\n| Pop Count           | [C++](Others/PopCount.cpp)                                       |      |\n| Sliding Windows     | [C++](Others/SlidingWindows.cpp)                                 |      |\n| String To Number    | [C++](Others/StringToNumber.py)                                  |      |\n| Sum                 | [C++](Others/Sum.cpp)                                            |      |\n| Ternary Search      | [C++](Others/TernarySearch.cpp)                                  |      |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminaminao%2Falgorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminaminao%2Falgorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminaminao%2Falgorithms/lists"}