Given an integer x, the task is to find if every k-cycle shift on the element produces a number greater than or equal to the same element.
A k-cyclic shift of an integer x is a function that removes the last k digits of x and inserts them in its beginning.
For example, the k-cyclic shifts of 123 are 312 for k=1 and 231 for k=2. Print Yes if the given condition is satisfied else print No.
Input: x = 123
Output : Yes
The k-cyclic shifts of 123 are 312 for k=1 and 231 for k=2.
Both 312 and 231 are greater than 123.
The k-cyclic shift of 2214 when k=2 is 1422 which is smaller than 2214
Approach: Simply find all the possible k cyclic shifts of the number and check if all are greater than the given number or not.
Below is the implementation of the above approach:
- Smallest number greater than or equal to N divisible by K
- Smallest Special Prime which is greater than or equal to a given number
- Generate all rotations of a number
- Find element at given index after a number of rotations
- Count number of triplets with product equal to given number with duplicates allowed
- Count number of subsets of a set with GCD equal to a given number
- Check if strings are rotations of each other or not | Set 2
- Check if two numbers are bit rotations of each other or not
- Check if a number is divisible by all prime divisors of another number
- Least Greater number with same digit sum
- Kth prime number greater than N
- Check if all rows of a matrix are circular rotations of each other
- Next greater number than N with exactly one bit different in binary representation of N
- Number of segments where all elements are greater than X
- Next greater Number than N with the same quantity of digits A and B
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.