← ALL NOTES
String

58. Length of Last Word

Scan from the end, not the start — it turns "find the last word" into a short walk over the tail. Skip any trailing spaces, then count non-space characters until you hit the next space. The one thing…

Loading…