Interview Solution

Let us change our traditional attitude to the construction of programs. Instead of imagining that our main task is to instruct a computer what to to, let us concentrate rather on explaining to human beings what we want a computer to do. Donald Knuth

Reverse String

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


Interview Problem

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


Given string 'Hello' and reverse string:olleH _



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.