You are viewing a single comment's thread. Return to all comments →
when we do:
s = scan.next()
s.length() is definitely greater than 1 as per constraints
but after:
s = s.trim()
all leading and trailing whitespaces are removed
hence if s = " " i.e. only white spaces then
s = " "
s.trim() will make s.length() == 0
as all white spaces are removed.
In 9th test case if you observe there is
non empty string filled with white spaces
as input hence I had to put that
if condition.
Seems like cookies are disabled on this browser, please enable them to open this website
Java String Tokens
You are viewing a single comment's thread. Return to all comments →
when we do:
s.length() is definitely greater than 1 as per constraints
but after:
all leading and trailing whitespaces are removed
hence if
s = " "
i.e. only white spaces thens.trim() will make s.length() == 0
as all white spaces are removed.
In 9th test case if you observe there is
non empty string filled with white spaces
as input hence I had to put that
if condition.