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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Mostly technology with occasional sprinkling of other random thoughts


Amir Amintabar's personal page

101 Books

Reading my way through Time Magazine's 100 Greatest Novels since 1923 (plus Ulysses)

Seek, Plunnge and more...

My words, my world...

ARRM Foundation

Do not wait for leaders; do it alone, person to person - Mother Teresa

Executive Management

An unexamined life is not worth living – Socrates


A topnotch site


Just another site

coding algorithms

"An approximate answer to the right problem is worth a good deal more than an exact answer to an approximate problem." -- John Tukey