Interview Question

Interview Seattle, WA

Reverse a string

Answer

Interview Answer

2 Answers

0

Using Python : def reverse(string): L = [] count = 1 for i in range(0,len(string)): L.append(string[len(string)-count]) count += 1 L_reverse = ''.join(L) return L_reverse

Anonymous on Apr 28, 2014
0

public String reverseMe(String string1) { int length = string1.length(); char[] charArray = new char[length]; int j = 0; for(int i = length -1 ; i >= 0 ; i--) { charArray[j++] = string1.charAt(i); } String string2 = new String(charArray); return string2; }

Vicky D on May 4, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.