I need to build a text editor as my mini project, and I need to design a data structure or algorithm that supports following operation:
- Append : Append a character at the end of the String.
- Prepend : Prepend a character at the beginning of the string.
- Search : Given a search string s, find all the occurrences of the string.
Each operation in O(log n) time or less. Search and replace operations will be appreciable but not necessary. The maximum length of string is constant. Any ideas how to achieve this?
Thanks!