reverse a string

Solutions on MaxInterview for reverse a string by the best coders in the world

showing results for - "reverse a string"
Amy
23 Jan 2017
1function reverseString(s){
2    return s.split("").reverse().join("");
3}
4reverseString("Hello");//"olleH"
Juan Diego
18 May 2020
1function reverseString(str) {
2    return str.split('').reverse().join('');
3}
4
5reverseString('string');    // "gnirts"
6
Victoria
25 Jun 2016
1//////////////////////////////////////
2function reverse(str) {
3  if(!str || str.length<2 || typeof str !== 'string'){
4    return 'hmmm that is not good...';
5  	}
6  return str.split('').reverse().join('');
7}
8
9//////////////////////////////////////
10function reverse(str) {
11  let n = str.length;
12  let s = '';
13  for (let i = n - 1; i >= 0; i--) {
14    s += str[i];
15  }
16  console.log(s);
17}
18reverse('Hello'); // olleH
Manel
22 Jan 2020
1let t = s.chars().rev().collect::<String>();
Rodrigo
06 Jan 2020
1public static String reverse(String orig)
2{
3    char[] s = orig.toCharArray();
4    int n = s.length;
5    int halfLength = n / 2;
6    for (int i=0; i<halfLength; i++)
7    {
8        char temp = s[i];
9        s[i] = s[n-1-i];
10        s[n-1-i] = temp;
11    }
12    return new String(s);
13}
14
Enola
13 Sep 2016
1String -- Reverse
2Write a return method that can reverse  String
3Ex: Reverse("ABCD"); ==> DCBA
4
5USING CORE JAVA
6public static String StrReverse(String str) {
7String reverse="";
8for(int i=str.length()-1; i >= 0; i--)
9reverse += str.toCharArray()[i];
10 
11return  reverse;
12}
13 
14USING STRING BUFFER/BUILDER
15public static String  Reverse(String str) {
16return new StringBuffer(str).reverse().toString();
17}
queries leading to this page
reverse a strigreversed stringwhat does string reverse returnwha is string reversestring reverse 28 29how to reverse a stinghow do u reverse a given string in placereversee a stringstring reversedoes reverse function works on stringreverse a string logichow to reverse string in algorithmget reverse of stringwhat type does string reverse returnhow to reverse the postion od stringconvert to string and reversefunction to reverse a string reverse a string with spceshow to reverse a string using invertreverse en un stringreverse a strinngreverse astringreverse a stringcode to reverse a stringreverse a string in placestrng reversehow to return reverse order of stringreverse a strhow to reverse string inhow to reverse a strinhow to reverse stringis it possible to use reverse 28 29 on stringreverse of a stringreverse string functionhow to reverse a stringreverse a strngstr reverse 28 29stirng reversereverse string logictransve a string in reversereverse a string programreverse function for stringsis string have reverse functiona function that prints a string in reversereverse string in strwrite a program to reverse a string reverse string onlinehow to reverse a string formulahow to reverse the string functionstring reversestring reverse 28 29reverse substring of a stringreturn reverse of stringreverse stirngreverse a astringstring reverse examplereverse string without strinfg functionreverse of a string using print functionswrite a function to reverse a stringreverse of a string using strrevreverse string functipnreverse string codecreate a reverse string functionstring reverse createrfunction reverse stringreverse string instring reverse function inreverse string o 281 29reverse string onsliehow to print a string in reversereverse a string in loophow to return the reverse of a stringmake a new string which is reverse of my strreverse string methodstring reverse functionreverse string in placehow to print reverse of stringprint string in reverseget a reverse stringhow to make a string backwardsreverse the whole string how to reverse a given stringreverse string programreverse string darwhich expression can be used to get reverse of a string str 3freverse string 3breverse find in stringreverse to stringhow to reverse string with defflip string backwardsreverse string recurtionstring reverse 23reverse method in stringreverse a text stringstring reverserreverse stringshow to reverse the stringreverse string orderreverse of stringreverse the string javstr reversereverse a strinreverse stringreverse a stinghow to reverse order on a stringhow to reverse stringsget value from string and reverse functioncreate a function to print the reverse of a stringcreating a function that reverse a string function that writes a string in reversehow to acces string in reverse orderfuntion to reverse a stringreverse order of a stringreverse a string javhow to reverse a string explanationreverse the stringreverse an stringwrite a function that accepts a string a reverses it function to know ia a string is the reverse of another stringwrite a program to reverse a stringmethod to reverse stringreverse side stringhow can you reverse a string 3freverse a string i avareverse function in stringreverse strhow to reverse a given string 3fhow to reverse astringreverse that stringreverse string wprdsstring comes reversereverse a given string in placereverse in string substringreverse a string namewhich of the following function is used to show reverse of stringreverse any string from mid finding reverse of a stringstring reverse stringhow to reverse the given stringrevers stringstring that reverse the valuereverse an string for ofto reverse a stringfunction to reverse stringfunction that reverse a stringreverse a stringreverse function for stringreversee a string by 1print reverse of stringreverse strinfunction to reverse stingreverse a given stringreverse a string algorithmprogram to reverse a stringfunction that reverses a stringstr reverse functionhow to access string in a reverse orderhow to write a string reversereverse a string functioncall the reverse of stringreverse the string programmanually reverse stringbest way to reverse a stringstring reverseword 28string str 29how can we reverse a string 2c without using any string functionsreverse string algorithmreverse a string