1. ## BuYS: Coding questions:

Suppose u have two strings......A and B....... then how will u find out whether B is rotation of A or not??
By rotation here what i mean is suppose A==GARAGE......... B=RAGEGA...... then B is the rotation of A..... RAGE IS NOT rotation of GARAGE.

HINT: I know it can be done via long coding....... but it can also be a one-liner.....
PS:dont google.. u vl get the ans.... or if some1 knows the trick... dont tell now u can write "I KNOW"....... for guys who dont know... plzz.. try....

Time Frame: 2 days

Lets take another example A====ORANGE:
from character 'N'
anticlock wise:B= NAROEG Its NOT
CLOCLWISE: B=NGEORA........... ITS Rotation
so we are considering her only Clockwise

2. By rotation here what i mean is suppose A==GARAGE......... B=RAGEGA....... then B is the rotation of A
but if B=RAGEGA... then it is not....
these appear to be contradictory
both place B=RAGEGA

3. Thanks for noticing :P actually i wanted to write them clockwise and anticlockwise.... from R....
original: GARAGE
anticlockwise: RAGEGA
clockwise:RAGEGA
both turned out to be same:
Lets take another example ORANGE:
from character 'N'
anticlock wise: NAROEG Its NOT
CLOCLWISE: NGEORA........... ITS Rotation
so we are considering her only Clockwise

4. common guys... no reply.......

5. Tried hard .. could'nt find the soln
PASS

6. Here is the answer:
return (A.length==B.length && (B.substring(A+A)))
LOGIC HERE is: if u replicate the first string...... twice.... then if B is the rotation of A then B will automatically become the substring
eg: A= ORANGE
B=NGEORA
A+A=ORANGEORANGE
NOW check B is the substring of A+A........
PS: above code is for java..... similar can be written for different lang.

7. I also pass but that was a good one

8. awesome observations. such things are really good to build up your coding skills.

thanks a ton

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•