This problem is not fun at all.
You spend 0.1% of the time on thinking of the algorithm, while 99.9% of the time on fighting against the ' ' and 'a' cases.
@agedboy agreed! the hint "If the last word does not exist, return 0." was misleading imo. i read it as "if the last character is a space, then the 'last word' doesn't exist" which made the problem unnecessarily more difficult /rant
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.