{"id":114,"date":"2017-08-02T19:13:21","date_gmt":"2017-08-02T11:13:21","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=114"},"modified":"2018-11-27T16:16:17","modified_gmt":"2018-11-27T08:16:17","slug":"58-length-of-last-word","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=114","title":{"rendered":"58. Length of Last Word"},"content":{"rendered":"<p>Given a string\u00a0<i>s<\/i>\u00a0consists of upper\/lower-case alphabets and empty space characters\u00a0<code>' '<\/code>, return the length of last word in the string.<\/p>\n<p>If the last word does not exist, return 0.<\/p>\n<p><b>Note:<\/b>\u00a0A word is defined as a character sequence consists of non-space characters only.<\/p>\n<p><b>Example:<\/b><\/p>\n<pre><b>Input:<\/b> \"Hello World\"\r\n<b>Output:<\/b> 5<\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def lengthOfLastWord(self, s):\r\n        &quot;&quot;&quot;\r\n        :type s: str\r\n        :rtype: int\r\n        &quot;&quot;&quot;\r\n        if s:\r\n            str_list = s.split()\r\n            if str_list:\r\n                return len(str_list[-1])\r\n        return 0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given a string\u00a0s\u00a0consists of upper\/lower-case alphabets<a href=\"https:\/\/www.ccagml.com\/?p=114\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">58. Length of Last Word<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/114"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=114"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}