Interview Solution

There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code. Flon's Law

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.