problem
stringlengths 167
1.48k
| code
stringlengths 21
1.09k
| label
int64 0
1
| full_sample
stringlengths 76
1.32k
| where_from
stringclasses 2
values |
---|---|---|---|---|
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=s.split(' ')[-1]
return len(word) if len(word)!=0 else 0
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=" | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+= | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans) | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
ans=len(s)
word=""
while s!="":
word+=s[-1]
s=s[:-1]
ans=len(word)
return(ans)
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len( | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1 | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_- | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s =='':
return 0
s = s.strip()
len_ = len(s)
i = 0
while i<len(s) and s[i] ==' ':
i += 1
return len_-i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = s.rfind(' ') + 1
return 0 if start == -1 else result - start
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = - | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] == | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i) | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
result = len(s)
start = len(s)-1
i = -1
while start >= 0:
if index := s[start] =='':
start -= 1
continue
i+=1
result = max(result, i)
if index == 0:
result = 0
return result
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
n = len(s)
return n-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
n = len(s)
return n-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
n = len(s)
return n-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
n = len(s | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
n = len(s)
return n-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
n = len(s)
return | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
else:
n = len(s)
return n-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.r | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1 | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\ | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
s=s.rstrip()
i=len(s)
while s[i-1] in'\t\r\n':
i=i-1
return i
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[ | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
| 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[ | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - | 0 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
if s == None:
return 0
words = s.split()
if len(words) == 1:
return len(words[0])
else:
return len(words[len(words) - 1])
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s. | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len( | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
| 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.r | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1 | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
# QUESTION:
# Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
#
# If the last word does not exist, return 0.
#
# Note: A word is defined as a character sequence consists of non-space characters only.
#
# Example:
#
# Input: "Hello World"
# Output: 5
# class Solution:
# def lengthOfLastWord(self, s: str) -> int:
#
# Use Call-Based format
# PYTHON CODE:
| class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 | 1 | class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
# for each char, there have to find the max character in the string
# if no char is found, return 0
# s.remove(' ')
# for each char, get the length of the word
# if the char is the last character, return
# else, return 0
# find the space in the string
# if the char is on the last word, return the length
# else, return 0
l = len(s)
i = s.rfind(' ') + 1
return l if i == -1 else i-1
| wrong |
End of preview. Expand
in Dataset Viewer.
- Downloads last month
- 0