LeetCode Length of Last Word Solution

A fairly simple problem with a couple of gotcha’s in what can be inputted. So let’s go through the details of it.

Pick Up | Credit: Marco Verch on Flickr (Creative Commons License)

Problem

So given a string consisting of some words separated by spaces, return the length of the last word. The key part, is that a word in this context contains only non-space characters. In short, is considered a word for simplicity sake.

--

--

Senior Brogrammer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store