It will contain programming related logical stuff.

Custom tokenizing of String

Maintain two pointers to tokenize string in custom way.  It can be implemented in any languages. Two pointer will be start chopping pointer and end chopping pointer, you have to calculate slots.

e.g. String is “My name is Deepesh Deomurari”.

Now we can start chopping to spaces as position

typical substring will be from SP to EP from String EP+1 + length of divider(in our case it is SPACE) to end of original String say remaining String. such as

for above String

At first cut

SP(Start Chopping Pointer): 0

EP(End Chopping Pointer): 1

Substring (SP,EP) =>My

Remaining String will be EP +1 +1(length of divider) => name is Deepesh Deomurari we can check till string lasts.

Note: Beware of index out of bound checks.

Prime Numbers Magic Rule:

You know most of the prime numbers follow 6n+-1 rule i.e. 6n+1,6n-1. So for checking any prime number you can check these conditions first.

Compare two sorted String

Easiest way is to maintain two pointers to track account of differences and we should know that if sorting parameter exceeded at one end then it will not be available forever e.g.

A => ab, ac, ae, ge, defghh

B => ac, ef, nh, ge

To find contains, taking B as base for comparision :

Check ‘ac’ found or not

Step 1: Pointer 0 failed, moved to 1 i.e. A->ac

Step 2: Found match break and increasing pointer of B i.e. B->ef. Increasing A to next pointer value moved to 2 A->ae

Step3: Checking again after previous break i.e., result FAILED(ae is not equal to ef).

Step4: Now moved to 3 A->ge, comparator denotes exceeding value Setting pointer to 3 only and updating pointer of B to B->nh and so on.

Note: You can extend relative search comparision to MxN comparisions.


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: