Leetcode - Length of Last Word (Python)

preview_player
Показать описание
September 2020 Leetcode Challenge
Leetcode - Length of Last Word
Рекомендации по теме
Комментарии
Автор

I wrote something similar to this at the start but I don't know why it was saying index out of range while submitting so I tried another optimized was
n, result = len(s), 0
while n>0:
n-=1
if s[n]!=" ": result +=1
elif result > 0: return result
return result

siddharthsingh
welcome to shbcf.ru