Ad

Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

Thursday, 18 July 2013

Algo#48: Find minimum window length which accommodate all given character.

Given problem is purely string manipulation problem. Here we have to find minimum window length which accommodate all given character for second string.

E.g. Given string ABBACBAA, and if we want to find minimum window length which can accommodate "AAA", it will be 5 (index 3 to 7). "CCC" should return MAX length as no window in original string can accommodate "CCC".

Following is implementation of above algorithm in c language.





Please write comments if you find anything wrong or you want to add something more related to this topic.

Saturday, 13 July 2013

Algo#43: Write basic function to implement atoi - Alpha to Integer

Function atoi is used to convert alphabetical string to integer. We can parse given string one character at a time, and convert it to integer. To make conversion fast enough, we can use bits manipulation for faster calculation.

Following is implementation of above problem in c language.





Please write comments if you find anything wrong or you want to add something more related to this topic.

Tuesday, 9 July 2013

Algo#39: Trim spaces from given string

Trim spaces from given string, can be asked in 2 ways. Removing all spaces from given string is easy to do than trimming only initial & end spaces.

Following is implementation of above problem in c language.





Please write comments if you find anything wrong or you want to add something more related to this topic.

Saturday, 6 July 2013

Algo#36: String passing from function

Many times we need to pass string from one function to other. There are different ways to do it. Each way has some method of allocating memory either in stack or heap. We need to be aware of allocation method when we use particular way.

Following is implementation of above concept in c language.





Please write comments if you find anything wrong or you want to add something more related to this topic.

Ad