“Minimum String Rotation”
Given a number N and N strings .
Output the minimum no. of rotations on the strings so as to make all the strings equal.
If this is not possible print -1.
Input
4
11234
34112
41123
11234
Output
3
finally all the strings would be 11234
first and last string input needs no rotations.
second needs 2 rotations.
third needs 1 rotation.
So total rotation will be 3.
No comments:
Post a Comment