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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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 18 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply