Hackwithinfy | Online Assessment | Minimum String Rotation

A rotation on a string is defined as removing first element and concatenating it at the end

Given N
and an array of N strings
Output the minimum no. of rotations on the strings so as to make all the strings equal.
If this is not possible return -1

example
4
11234
34112
41123
11234
ouput
3

finally all the strings would be 11234
first and last string input needs no rotations
second needs 2 rotations
third 1 rotation

Comments (11)