ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
I solved this using String.trim() function .
that's why use cpp for logic building
Excellent bro without trim function
Excellent solution
Your explanation is very good and easy to grasp love your videos ❤️ keep growing
thanks for your wishes
class Solution { public int lengthOfLastWord(String s) { String[] args = s.split(" "); String wrd = args[args.length-1]; return wrd.length(); }}
great
Thank you Nikhil, Can you just explain me how else{ if(count>0) return count; }this works??
check the 3 line comment. what are you struggling with?
public int lengthOfLastWord(String s) { int count=0; for(int i=s.length()-1;i>=0;i--) { if(s.charAt(i)!=' ') { count=count+1; } else if(s.charAt(i)==' '&&count>=1) { break; } } return count; }} enjoy bachoooo
Sure
Thanks, could you make a video of Leetcode 22. "Generate Parentheses" problem solution with DP?
gonna make it soon
Does it work if the input is a single character
you are the best !!
I'm asking you to make a videos hoe to input a tree, how to output a tree, most common trees in CP
🤘
can we use trim() method na two remove the spaces
Yes we can
String[] arr = str.split(" "); String lastWord = arr[arr.length-1]; return lastWord.length();what about this code
works perfectly as well
But input is single word how to find bro
If single word, then that is the last word. So just return its length
@@nikoo28 if one word occurs just return 0 bro
runtime error aa raha h bhai
check the code in the video description
int lengthOfLastWord(string s) { int i=0; int ans; for(i=0;i
I solved this using String.trim() function .
that's why use cpp for logic building
Excellent bro without trim function
Excellent solution
Your explanation is very good and easy to grasp love your videos ❤️ keep growing
thanks for your wishes
class Solution
{
public int lengthOfLastWord(String s)
{
String[] args = s.split(" ");
String wrd = args[args.length-1];
return wrd.length();
}
}
great
Thank you Nikhil, Can you just explain me how
else{
if(count>0)
return count;
}
this works??
check the 3 line comment. what are you struggling with?
public int lengthOfLastWord(String s) {
int count=0;
for(int i=s.length()-1;i>=0;i--)
{
if(s.charAt(i)!=' ')
{
count=count+1;
}
else if(s.charAt(i)==' '&&count>=1)
{
break;
}
}
return count;
}
} enjoy bachoooo
Sure
Thanks, could you make a video of Leetcode 22. "Generate Parentheses" problem solution with DP?
gonna make it soon
Does it work if the input is a single character
you are the best !!
I'm asking you to make a videos hoe to input a tree, how to output a tree, most common trees in CP
🤘
can we use trim() method na two remove the spaces
Yes we can
String[] arr = str.split(" ");
String lastWord = arr[arr.length-1];
return lastWord.length();
what about this code
works perfectly as well
But input is single word how to find bro
If single word, then that is the last word. So just return its length
@@nikoo28 if one word occurs just return 0 bro
runtime error aa raha h bhai
check the code in the video description
int lengthOfLastWord(string s) {
int i=0;
int ans;
for(i=0;i