Interview Solution

First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack. George Carrette

Reverse String

Language Java | Level Intermediate | Category Interview Problems | July 24, 2015 4:52 pm

Comments


Interview Problem

Reverse the given string without using the build in functions.
Write program to reverse the string without using any inbuilt functions
Example:-
Given string "hello" return "olleh"


Output

   					 
Given string 'Hello' and reverse string:olleH _

				    

Comments

Posted by secret2006is
March 23, 2016 9:52 am

public static String reverse(String s) { StringBuilder sb = new StringBuilder(); for (int i = s.length() - 1; i >= 0; i--) sb.append(s.charAt(i)); return sb.toString(); }



Please login to add comments.