Skip to content

Conversation

@gopaljilab
Copy link
Contributor

Summary

This pull request introduces the LengthOfLastWord algorithm under the strings package.
It also includes comprehensive JUnit test coverage to ensure correctness and reliability.

Details

  • LengthOfLastWord.java
    Implements a method to compute the length of the last word in a given string.
    The algorithm efficiently traverses the string from the end to handle trailing spaces.

  • LengthOfLastWordTest.java
    Adds JUnit tests covering various scenarios, including:

    • Strings with trailing spaces
    • Single-word inputs
    • Multiple-word inputs
    • Empty string edge case

Checklist

  • Code follows the repository’s naming and structural conventions
  • Includes Javadoc-style documentation
  • Added unit tests for all relevant cases
  • Verified all tests pass locally using ./gradlew test

Example

Input: "Hello World"
Output: 5

@gopaljilab
Copy link
Contributor Author

👋 Hello, this is my first open-source contribution!
I’ve implemented the LengthOfLastWord algorithm under the strings package and added JUnit tests for validation.
Please review and let me know if any improvements are needed.
Thank you for maintaining this amazing repository! 🙏

@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.89%. Comparing base (48e02b3) to head (228aa08).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7057      +/-   ##
============================================
- Coverage     78.90%   78.89%   -0.01%     
- Complexity     6858     6863       +5     
============================================
  Files           771      772       +1     
  Lines         22688    22697       +9     
  Branches       4457     4459       +2     
============================================
+ Hits          17901    17907       +6     
- Misses         4072     4073       +1     
- Partials        715      717       +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.

@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) December 20, 2025 13:39
@DenizAltunkapan DenizAltunkapan merged commit bb33488 into TheAlgorithms:master Dec 20, 2025
7 checks passed
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