Reverse words in a string | Leetcode problem 151
Reverse words in a String
Leetcode problem number 151
JAVA interview programming playlist:
• Interview Programming ...
#java #interviewquestions #leetcode
Reverse words in a String
Leetcode problem number 151
JAVA interview programming playlist:
• Interview Programming ...
#java #interviewquestions #leetcode
Пікірлер: 28
such a sweet and simple solution, thank q mam.
hats off to your dediication towards your work and professionalism
@TechnosageLearning
Жыл бұрын
Thankyou!!💐
thanks for the beautiful explanation . also your voice was very pleasent to my ears .
Your's teaching is excellant mam. Put more videos mam. And I humbly request to give time complexity for the each problem
Fantastic
How can we write without split function
Good explanation.!!
Keep teaching mam😊
Thank u mam
mam ,plz maintain git link to store all codes
Love your explanation ❤
Nice 👍👍👍👍 ma'am 🥰 you
mam why we are using + for s.split(" ");
@kishnersuperbannumiyer7383
3 ай бұрын
+ means any number of spaces ko break krna
In this question given space complexity: o(1)
@amritabill3306
Жыл бұрын
Hello, The problem says, "if string data type is mutable in your language, can you solve it in place with O(1) extra space" Since here the problem is solved using JAVA, where the Strings are immutable in nature.
@Jai_Jai_shri_Ram108
Жыл бұрын
@@amritabill3306 ok
Mam while executing the same we are getting errors mam ( : , s,regex , its showing as illegal expressions ) and while we are taking the inputs from user also we are facing the issue
@TechnosageLearning
10 ай бұрын
Hi Can you please copy the code from git repo and give it a try..you might be missing something while writing regex
@rjsuryavanshi922
3 ай бұрын
no need to write regex as it is automatically done by ide in intelliJ
stack can be a better
Hi, I am trying to do reverse the words which is separated by dot. Here is an example and code String inp = " Welcome.to.Java.Programming "; static String reverseWords(String str) { String rev =""; str = str.trim(); String[] words = str.split("\\."); StringBuilder sb = new StringBuilder(); for (int i = words.length -1 ; i >= 0; i--) { sb.append(words[i]); sb.append("."); } return sb.toString().trim(); } Output: Programming.Java.to.Welcome. I could see dots are getting added for each iteration which makes the incorrect output. Could you please check and suggest me how to handle the situation
@chetankumar5190
3 ай бұрын
you are appending dots that's why they are appearing sb.append(".")
@ashokkumar-nb8ri
3 ай бұрын
@@chetankumar5190 yes I am appending the dot, because input string is with dot. So I want to reverse the words and append the dots too. Like how they append the space in this video But my question is when appending its appending after last word also Check out the output in my comment
@chetankumar5190
3 ай бұрын
More what, u want dot or not
@ashokkumar-nb8ri
3 ай бұрын
@@chetankumar5190 I am expecting below output Programming.Java.to.Welcome
@chetankumar5190
3 ай бұрын
Add condition If(i!=s.length()-1) sb .append(.)