Page 1 of 1

Hello, for this question, we want to return the length of the length of the last word of a string. I was wondering why t

Posted: Fri May 20, 2022 10:41 am
by answerhappygod
Hello, for this question, we want to return the length of the
length of the last word of a string. I was wondering why the method
that I used returns the wrong number.
Thanks!
Hello For This Question We Want To Return The Length Of The Length Of The Last Word Of A String I Was Wondering Why T 1
Hello For This Question We Want To Return The Length Of The Length Of The Last Word Of A String I Was Wondering Why T 1 (67.44 KiB) Viewed 20 times
1 2 3 4 5 6 7 class Solution { public int lengthOfLastWord(String s) { String[] ary = s.split(""); for (int i = 0; i < ary.length; i++) { if (ary "") { return ary.length - i; == } } return 0 REBO Java } 11 12 } Testcase Run Code Result Debugger Wrong Answer Runtime: 0 ms Your input "Hello World" Output 0 Diff Expected 5