# Strings

**TIPS: **Algorithms on Strings/Character_Arrays can be dealt with pointers. Taking pointers one at the beginning of the array and one at the end of the array (using length of the array) will be helpful in solving string algorithms.

algorithm to reverse a string in O(n/2) complexity: There are many ways of reversing a string but best possible case should be considered keeping space and time complexities in mind. Psuedocode for O(n/2) complexity…

algorithm to reverse words of a string: This is a bit tricky algorithm and most frequently asked question in interviews. I will now show how to do it in best time complexity [O(2n)]….

algorithm to find first unrepeated character in a string: We can do it in two different ways; Algorithm with O(2n) time complexity and O(1) space complexity; Algorithm with O(2n) time complexity and O(n) space complexity

algorithm to find substring in a string (KMP Algorithm): Knuth-Morris-Pratt Algorithm (KMP) detailed analysis – Understanding this would show us what a careful algorithmic thinker would code even for a small problem like this. This is one of the algorithms which is easy to implement but one needs lot of attention and hard work to understand the algorithm.

## Recent Comments