You are viewing a single comment's thread. Return to all comments →
But using StringBuilder increases space complexity.
Your code has space complexity O(N). Where N is length of string.
If you simply print it took O(1).
he said "reusability." if he's concerned with complexity then print.
do your work....