A K-periodic string is a circular string that remains same when it is rotated by K units. Given a circular string s, find whether there exists a permutation of string s which is a K periodic circular string and if it exists then find lexicographically smallest permutation of s which is a K periodic circular string. Return empty string if there does not exist a valid permutation of s which is a K-period string. Note: You can rotate the string in any direction.
Example 1 : s = "abba" k = 2 Output 1 : "abab"
Example 2 : s = "abbbbbb" k = 4 Output 2 : ""
Constraints : 1 <= length of string s <= 1e5 1 <= k <= 1e9
Please help in this problem and tell your approach to the problem
Auto comment: topic has been updated by code_tycoon (previous revision, new revision, compare).
Observation:
If the ith character is c then each of the following characters
i, (i + k) % n, (i + 2 * k) % n, (i + 3 * k) % n, ...
should also be cPlease provide the link to the problem too . So that we can write our solution to check whether if it is correct or not.
Access Problem Here
Thanks