Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-04-26_18-14-20.png
27.3 KB
#N58. Length of Last Word
problem link
#solution
class Solution {
public int lengthOfLastWord(String s) {
int count=0;
for(int i=s.length()-1; i>=0; i--){
if(s.charAt(i)==' ' && count!=0) break;
if(s.charAt(i)!=' ') count++;
}

return count;
}
}