- Notifications
You must be signed in to change notification settings - Fork20.7k
Implement LengthOfLastWord algorithm and add JUnit tests#7057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Conversation
gopaljilab commentedNov 8, 2025
👋 Hello, this is my first open-source contribution! |
codecov-commenter commentedNov 8, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## master #7057 +/- ##========================================== Coverage 78.34% 78.35%- Complexity 6621 6676 +55========================================== Files 747 754 +7 Lines 22036 22194 +158 Branches 4322 4358 +36 ==========================================+ Hits 17264 17390 +126- Misses 4085 4105 +20- Partials 687 699 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
This pull request introduces the
LengthOfLastWordalgorithm under thestringspackage.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:
Checklist
./gradlew testExample
Input: "Hello World"
Output: 5