I faced an interview today and I was asked to reverse a string in single operation . I was feeling like it is impossible in less than O(n) . By the way , I was given a clue , "Swapping" ! So . . . does any answer exist ?
- Sample Input : "abcdefghi" (or , any strings )
- Sample Output :"ihgfedcba"
- No built in function can be used . ( ex :
strrev()) - The answer is not tricky like just printing/iterating reversely .