:type s: str :rtype: int
(self, s)
| 12 | """ |
| 13 | class Solution(object): |
| 14 | def lengthOfLastWord(self, s): |
| 15 | """ |
| 16 | :type s: str |
| 17 | :rtype: int |
| 18 | """ |
| 19 | if not s: |
| 20 | return 0 |
| 21 | |
| 22 | result = 0 |
| 23 | flag = False |
| 24 | |
| 25 | for i in s[::-1]: |
| 26 | if i == ' ' and not flag: |
| 27 | continue |
| 28 | elif i == ' ' and flag: |
| 29 | return result |
| 30 | else: |
| 31 | result += 1 |
| 32 | flag = True |
| 33 | continue |
| 34 | |
| 35 | return result |
| 36 | return result |
nothing calls this directly
no outgoing calls
no test coverage detected