a interview question solved in ReverseString2.java