Java DSA: Length of Last Word in String

🚀 Day 27 / 180 – DSA with Java 🚀 📘 Topic Covered: Strings & Reverse Traversal 🧩 Problem Solved: Length of Last Word Problem: Given a string containing words separated by spaces, find the length of the last word. Approach: Started traversing the string from the end, skipped trailing spaces first, and then counted characters until encountering another space or reaching the beginning of the string. Key Learning: ✔️ Efficient reverse traversal in strings ✔️ Handling edge cases like trailing spaces ✔️ Writing simple yet optimized string logic If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Strings #ProblemSolving #Consistency

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories