Company: Infoedge_12oct
Difficulty: medium
String Motor Problem Description A String Motor is a device that takes a string S and a value K from the user as input and returns a string as an output. The output string is the string obtained by rotating the input string by k characters in the backward direction. For example, if the input string is "doselect" and k is 2, then the output string would be "selectdo". Input Format The first line contains a string S. The second line contains an integer K. Constraints 1 <= S.size() <= 10 5 0 <= K <= S.size() Output Format Output must contain a single string. Examples Example 1: Input: S = "doselect", K = 2 Output: "selectdo" Explanation: The input string S is "doselect". The rotation value K is 2. Step-by-step rotation process: Since the rotation is backward by 2 characters, you take the substring starting at index 2 to the end of the string: S[2:] = "select" Then append the substring from the start of the string up to index 1 (which is K - 1): S[0:2] = "do" Concatenate these