• + 2 comments

    If I am not mistaken the complexity of your algorithm would be O( N^2 ). Given the fact that in a data structure up to 26 characters would be stored I would suggest maybe using a hashset so it may run in O( N ). Overall, I liked your different approach.