Reverse Words in a String | LeetCode 151 | Reverse String Word by Word | Multiple Approaches

preview_player
Показать описание
In this tutorial, I have explained multiple approaches to solve reverse words in a String LeetCode Problem. In this problem, we have to reverse string word by word.

Given an input string, reverse the string word by word.

Reverse String word by word in Java.

LeetCode July Challenge Day 15.

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

what is the time and space complexity of the string builder solution

shefalithakur
Автор

Sir how to arrange array first largest second smallest second largest second smallest??? Help me write program for this

mohammedajazquadri
Автор

Class RevWords
{
P.s.v.m()

{
String s="How are you"+" "
// Adding extra space so that it becames easy too write logic
String rev=" ";
String word=" ";
Char ch;
Int n =s.length();
For(int i=0;i<n;i++)
{
Ch=s.charAt(i);
//For taking one one character
If(ch!=' ')
// Not equal to space add in the word
Word =word+ch;
Else
// Not equal to add in rev
Rev=word+ " "+rev;
Word=" ";
}
S.o.p(rev);

mohammedajazquadri