Meta Interview Question

Nothing difficult. Reverse String Pair words that are Anagrams of each other.

Interview Answers

Anonymous

Dec 9, 2014

They expect you to write code that would compile and want you be write it super fast. So practice a lot before test.

Anonymous

Dec 12, 2014

public String reverseString(String s) { StringBuilder sb = new StringBuilder(); for(int i=s.length()-1; i>=0; i--) { sb.append(s.charAt(i)); } return sb.toString(); } public String reverseSentence(String s) { String r = this.reverseString(s); int start = 0; StringBuilder result = new StringBuilder(); for(int i=0; i<=r.length(); i++) { if( r.length()==i || r.charAt(i)==' ') { String word = r.substring(start,i); String reversed = reverseString(word); result.append(reversed); if (r.length()!=i){ result.append(' '); } start = i +1; } } return result.toString(); }