fork download
  1. class Solution:
  2. def lengthOfLastWord(self, s: str) -> int:
  3. substr = ''
  4.  
  5.  
  6. for i in range(len(s)-1,0,-1) :
  7. if s[i] == ' ' and len(substr) > 0:
  8. return len(substr)
  9. if s[i] != ' ' :
  10. substr += s[i]
  11.  
Success #stdin #stdout 0.03s 9656KB
stdin
Standard input is empty
stdout
Standard output is empty