Strings : Remove duplicate characters from string This is very trivial problem asked during interviews. It checks two fundamentals. One ability to work with string and other familiarity with concept of hash. Problem statement Given a string S, remove all the duplicate characters. Only one instance of character should remain in resultant string. Analysis Brute force algorithm would be do scan whole array for the given character and remove all its instances.Once done for all characters, arrange remaining characters in emptied spaces. Complexity of above algorithm will be O(N^2).
Read full article from Algorithms and Me: Strings : Remove duplicate characters from string
No comments:
Post a Comment