Don't know why my solution don't work

  • 0

    Here is my code:
    '''class Solution(object):
    def lengthOfLastWord(self, s):
    :type s: str
    :rtype: int
    count = 0
    if not s:
    return 0
    for i in s[::-1]:
    if i == ' ':
    return count
    count += 1
    return count'''
    I use pycharm to input 'a' , pycharm output 1. However, the Leetcode output 0.
    It frustrates a lot.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.