Question: please answer the following in CPP in detail ty String Rotations [10 points) A string rotation is defined as taking the first character and placing
please answer the following in CPP in detail ty

String Rotations [10 points) A string rotation is defined as taking the first character and placing it in the last position or taking the last character and placing it in the first position (left and right rotations respectively). The rotation distance between two strings is the minimum number of rotations needed to be performed on one string so that it is equal to the other. If the strings can not be transformed into one another, then their distance is -1. Examples: "ABCD", and "BCDA" have a distance of 1, because we needed to rotate "ABCD" once. The strings "ABCD", "BCAD" have a distance of -1 because they can not be rotated into each other. Write a function in your lab3.h header file with the following signature: int rotation_distance( std::string a, std::string b) which returns the rotation distance of the given strings
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
