Complexity Analysis:
- Time Complexity:
$O(n)$ .$n$ is the length of input String. - Space Complexity:
$O(1)$ . We only use constant size of array. The input of sorting is constant as well. Thus, the total space complexity is$O(1)$ .
Complexity Analysis: