Note: If you use StringBuilder then you can use it's reverse method to reverse the string. It does not make sense to create StringBuilder object to just append small String. Even interviewer may ask you reverse a string without using any built-in reverse methods or additional classes like StringBuilder or StringBuffer. Use StringBuilder for concatenating or appending long strings. This can be a most efficient way to reverse a string in Java without build-in method
@thatguyadarsh
5 ай бұрын
Little modification: we can use stringbuilder instead of concatenation. Thanks for your videos!! 😊
@prof.mangabhai
5 ай бұрын
in a interview this wouldn't be satisfactory, since everytime we are making a new string when concating a new character, so for super large strings it is not advised to use this method, use a stringbuilder or a char[] (which can be later converted to string by toString() method)
@VasyaFF
5 ай бұрын
Is this a better way to use: `i >= input.length / 2` and each iteration swap first and last chars?
@Kamrankhan23333
5 ай бұрын
Can you make one using stack ds?
@Maruthi468
4 ай бұрын
Use StringBuilder with append instead of result = result + i-value
@guohaofrankwu7317
5 ай бұрын
is the time complexity Big-O O(n)? if using reverse can reduce the time complexity
@Yaduvanshi-nw3yr
4 ай бұрын
Another way using recursion method
@phusicus_404
5 ай бұрын
You've chosen the most inefficient approach. Delete the video and think of what you have done.
@JavaGuides
5 ай бұрын
You show me efficient approach
@nabinghoshmaths6834
5 ай бұрын
@@JavaGuides May be we can use Stringbuffer to append the character. But this way is also fine.
@JavaGuides
5 ай бұрын
If you use StringBuilder then you can use it's reverse method to reverse the string. It does not make sense to create StringBuilder object to just append small String. Even interviewer may ask you don't use any other classes and in-built methods other than String.
@phusicus_404
5 ай бұрын
@@JavaGuidesSwap characters from both halves of the string from the ends to the middle. It was among the comments.
Пікірлер: 14