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
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)
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.
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
Little modification: we can use stringbuilder instead of concatenation.
Thanks for your videos!! 😊
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)
Is this a better way to use: `i >= input.length / 2` and each iteration swap first and last chars?
Use StringBuilder with append instead of result = result + i-value
is the time complexity Big-O O(n)? if using reverse can reduce the time complexity
Can you make one using stack ds?
Another way using recursion method
You've chosen the most inefficient approach. Delete the video and think of what you have done.
You show me efficient approach
@@JavaGuides May be we can use Stringbuffer to append the character. But this way is also fine.
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.
@@JavaGuidesSwap characters from both halves of the string from the ends to the middle.
It was among the comments.
Solve it recursively. It's most efficient 😂