Skip to content

Conversation

BEASTSHRIRAM
Copy link
Contributor

After contributing to TheAlgorithms, I realized many CP students visit this repository for learning resources. I've added two important algorithms that were missing:

  1. Mo's Algorithm - Square root decomposition for offline range queries(https://www.geeksforgeeks.org/dsa/mos-algorithm-query-square-root-decomposition-set-1-introduction/)(https://codeforces.com/blog/entry/7383)

    • Essential for competitive programming contests
    • O(n√n) time complexity for multiple range queries
    • Very common in Codeforces and other CP platforms
  2. DiceThrower - Recursive backtracking for dice combinations

    • Great example of recursion and backtracking
    • Helps students understand recursive problem-solving
    • Generates all possible dice roll combinations for target sum

Both algorithms include comprehensive test suites and follow all contribution guidelines. These will help students build stronger foundations in competitive programming.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

- Mo's Algorithm: Square root decomposition for offline range queries(Imp in CP)
- DiceThrower: Recursive backtracking for dice combinations(very imp)
- Both algorithms include comprehensive test suites
- Formatted with clang-format and i follow contribution guidelines
@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 97.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.06%. Comparing base (596302b) to head (d9ad6a6).

Files with missing lines Patch % Lines
...in/java/com/thealgorithms/others/MosAlgorithm.java 97.80% 0 Missing and 2 partials ⚠️
.../java/com/thealgorithms/recursion/DiceThrower.java 96.55% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6591      +/-   ##
============================================
+ Coverage     75.93%   76.06%   +0.13%     
- Complexity     5845     5885      +40     
============================================
  Files           707      709       +2     
  Lines         19965    20085     +120     
  Branches       3871     3897      +26     
============================================
+ Hits          15160    15278     +118     
  Misses         4219     4219              
- Partials        586      588       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BEASTSHRIRAM
Copy link
Contributor Author

BEASTSHRIRAM commented Oct 2, 2025

there was an dicethrow.java file but it mainly focuses on finding the number of ways to get sum x with n dice, each having m faces. but mine is is not a problem it gives recursive and backtracking approach.
Literally it is great to contribute in such a helpful website great work guys , please merge this work @alxkm .
Love from INDIA

@BEASTSHRIRAM
Copy link
Contributor Author

BEASTSHRIRAM commented Oct 5, 2025

@alxkm i have fixed partitionproblem.java file and also fixed Mos algorithm and Dicethrower which i had commited but got less patch coverage by codecov please merge this commit under hacktoberfest 2025

Copy link
Member

@DenizAltunkapan DenizAltunkapan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m fine with the proposed algorithms

@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) October 8, 2025 11:48
@DenizAltunkapan DenizAltunkapan merged commit 959ced9 into TheAlgorithms:master Oct 8, 2025
6 checks passed
@BEASTSHRIRAM
Copy link
Contributor Author

Thankyou so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants