Reverse words in a string | Leetcode problem 151

preview_player
Показать описание
Reverse words in a String
Leetcode problem number 151

JAVA interview programming playlist:

#java #interviewquestions #leetcode
Рекомендации по теме
Комментарии
Автор

hats off to your dediication towards your work and professionalism

inspiremusicandinspirephar
Автор

thanks for the beautiful explanation . also your voice was very pleasent to my ears .

anshumankumarnathshahdev
Автор

Your's teaching is excellant mam. Put more videos mam. And I humbly request to give time complexity for the each problem

thulasiramans
Автор

such a sweet and simple solution, thank q mam.

rajdeeppatil
Автор

How can we write without split function

naveennaidu
Автор

mam why we are using + for s.split(" ");

VinaySangem
Автор

mam, plz maintain git link to store all codes

VinaySangem
Автор

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

kandukuriveeranikhil
Автор

In this question given space complexity: o(1)

Jai_Jai_shri_Ram
Автор

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

ashokkumar-nbri