![]() |
Given a circular string s, find whether there exists a permutation of s which is a K-periodic circular string and if it exists then find the lexicographically smallest permutation of s which is a K-periodic circular string. Return an empty string if there does not exist a valid permutation of s which is a K-periodic circular string.
Examples:
Approach: This can be solved with the following idea:
Below are the steps involved:
Below is the implementation of the code: C++
Java
Python3
C#
Javascript
Output
-1 Time Complexity: O(n*log n) |
Reffered: https://www.geeksforgeeks.org
DSA |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |