{"id":"c33ca292-4702-4987-8eb5-4e0c43e6b3ef","name":"Rotate A Number","description":"1. You are given two numbers n and k. You are required to rotate n, k times to the right. If k is positive, rotate to the right i.e. remove rightmost digit and make it leftmost. Do the reverse for negative value of k. Also k can have an absolute value larger than number of digits in n.\r\n2. Take as input n and k.\r\n3. Print the rotated number.\r\n4. Note - Assume that the number of rotations will not cause leading 0's in the result. e.g. such an input will not be given\r\n n = 12340056\r\n k = 3\r\n r = 05612340","inputFormat":"\"n\" where n is any integer.\r\n\"K\" where k is any integer.","outputFormat":"\"r\", the rotated number","constraints":"1 &lt;= n &lt; 10^9\r\n-10^9 &lt; k &lt; 10^9","sampleCode":{"cpp":{"code":"#include <iostream>\r\n#include<cmath>\r\n\r\nusing namespace std;\r\nint main(){\r\n int n,k;\r\n cin>>n>>k;\r\n \r\n //write your code here\r\n\r\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n // write your code here \r\n }\r\n }"},"python":{"code":"def rotate(n,k):\n # write your code here\n\ndef main():\n n = int(input())\n k = int(input())\n rotate(n,k)\n\nif __name__==\"__main__\":\n main()"}},"points":10,"difficulty":"easy","sampleInput":"562984\r\n2","sampleOutput":"845629","questionVideo":"https://www.youtube.com/embed/ysMHtDIlU0c","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"72157774-7fd0-4b8e-88dc-037800acd626","name":"Getting Started","slug":"getting-started-9996","type":0},{"id":"9c36d490-8902-4485-9c31-0ee51b435162","name":"Rotate A Number","slug":"rotate-a-number","type":1}],"next":{"id":"4f012c45-f101-4da4-91c8-c663b567bdca","name":"Rotate a Number","type":3,"slug":"rotate-a-number"},"prev":{"id":"4cab2495-4e65-44b3-a700-8a990704f4bb","name":"Inverse a Number","type":3,"slug":"inverse-a-number"}}}

Rotate A Number

1. You are given two numbers n and k. You are required to rotate n, k times to the right. If k is positive, rotate to the right i.e. remove rightmost digit and make it leftmost. Do the reverse for negative value of k. Also k can have an absolute value larger than number of digits in n. 2. Take as input n and k. 3. Print the rotated number. 4. Note - Assume that the number of rotations will not cause leading 0's in the result. e.g. such an input will not be given n = 12340056 k = 3 r = 05612340

{"id":"c33ca292-4702-4987-8eb5-4e0c43e6b3ef","name":"Rotate A Number","description":"1. You are given two numbers n and k. You are required to rotate n, k times to the right. If k is positive, rotate to the right i.e. remove rightmost digit and make it leftmost. Do the reverse for negative value of k. Also k can have an absolute value larger than number of digits in n.\r\n2. Take as input n and k.\r\n3. Print the rotated number.\r\n4. Note - Assume that the number of rotations will not cause leading 0's in the result. e.g. such an input will not be given\r\n n = 12340056\r\n k = 3\r\n r = 05612340","inputFormat":"\"n\" where n is any integer.\r\n\"K\" where k is any integer.","outputFormat":"\"r\", the rotated number","constraints":"1 &lt;= n &lt; 10^9\r\n-10^9 &lt; k &lt; 10^9","sampleCode":{"cpp":{"code":"#include <iostream>\r\n#include<cmath>\r\n\r\nusing namespace std;\r\nint main(){\r\n int n,k;\r\n cin>>n>>k;\r\n \r\n //write your code here\r\n\r\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n // write your code here \r\n }\r\n }"},"python":{"code":"def rotate(n,k):\n # write your code here\n\ndef main():\n n = int(input())\n k = int(input())\n rotate(n,k)\n\nif __name__==\"__main__\":\n main()"}},"points":10,"difficulty":"easy","sampleInput":"562984\r\n2","sampleOutput":"845629","questionVideo":"https://www.youtube.com/embed/ysMHtDIlU0c","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"72157774-7fd0-4b8e-88dc-037800acd626","name":"Getting Started","slug":"getting-started-9996","type":0},{"id":"9c36d490-8902-4485-9c31-0ee51b435162","name":"Rotate A Number","slug":"rotate-a-number","type":1}],"next":{"id":"4f012c45-f101-4da4-91c8-c663b567bdca","name":"Rotate a Number","type":3,"slug":"rotate-a-number"},"prev":{"id":"4cab2495-4e65-44b3-a700-8a990704f4bb","name":"Inverse a Number","type":3,"slug":"inverse-a-number"}}}
plane

Editor


Loading...

Rotate A Number

easy

1. You are given two numbers n and k. You are required to rotate n, k times to the right. If k is positive, rotate to the right i.e. remove rightmost digit and make it leftmost. Do the reverse for negative value of k. Also k can have an absolute value larger than number of digits in n. 2. Take as input n and k. 3. Print the rotated number. 4. Note - Assume that the number of rotations will not cause leading 0's in the result. e.g. such an input will not be given n = 12340056 k = 3 r = 05612340

Constraints

1 <= n < 10^9 -10^9 < k < 10^9

Format

Input

"n" where n is any integer. "K" where k is any integer.

Output

"r", the rotated number

Example

Sample Input

562984 2

Sample Output

845629

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode