Skip to content

feat(strings): add MoveHashToEnd algorithm#7313

Open
ShyamChavda005 wants to merge 5 commits intoTheAlgorithms:masterfrom
ShyamChavda005:feature/move-hash-to-end
Open

feat(strings): add MoveHashToEnd algorithm#7313
ShyamChavda005 wants to merge 5 commits intoTheAlgorithms:masterfrom
ShyamChavda005:feature/move-hash-to-end

Conversation

@ShyamChavda005
Copy link

@ShyamChavda005 ShyamChavda005 commented Mar 14, 2026

  • Add MoveHashToEnd utility class that moves all '#' characters to the end of a string while preserving the order of other characters
  • Algorithm runs in O(n) time and O(n) space using a two-pass approach: first collects non-'#' chars, then fills remaining positions with '#'
  • Add null and empty string guards
  • Add MoveHashToEndTest with 9 unit tests covering normal, edge, and boundary cases (null, empty, all-hash, no-hash, single char)
  • 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 algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

- Add MoveHashToEnd utility class that moves all '#' characters
  to the end of a string while preserving the order of other characters
- Algorithm runs in O(n) time and O(n) space using a two-pass approach:
  first collects non-'#' chars, then fills remaining positions with '#'
- Add null and empty string guards
- Add MoveHashToEndTest with 9 unit tests covering normal, edge,
  and boundary cases (null, empty, all-hash, no-hash, single char)
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.45%. Comparing base (5e06b15) to head (a4e248a).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7313   +/-   ##
=========================================
  Coverage     79.44%   79.45%           
- Complexity     7064     7069    +5     
=========================================
  Files           788      789    +1     
  Lines         23129    23139   +10     
  Branches       4548     4551    +3     
=========================================
+ Hits          18375    18385   +10     
  Misses         4022     4022           
  Partials        732      732           

☔ 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.

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.

2 participants