Given a string str and an integer K, the task is to check whether the given string is K-periodic. A string is k-periodic if the string is a repetition of the sub-string str[0 … k-1] i.e. string “ababab” is 2-periodic. Print Yes if the given string is k-periodic else print No.
Input: str = “geeksgeeks”, k = 5
Given string can be generated by repeating the prefix of length k i.e. “geeks”
Input: str = “geeksforgeeks”, k = 3
Approach: Starting with the sub-string str[k, 2k-1], str[2k, 3k-1] and so on, check whether all of these sub-strings are equal to the prefix of the string of length k i.e. str[0, k-1]. If the condition is true for all such sub-strings then print Yes else print No.
Below is the implementation of the above approach:
- String slicing in Python to check if a string can become empty by recursive deletion
- Check if a string can be converted to another string by replacing vowels and consonants
- Check if a string can become empty by recursively deleting a given sub-string
- Queries to check if string B exists as substring in string A
- Check if a string can be obtained by rotating another string 2 places
- Check if a string can be obtained by rotating another string d places
- Check if a string can be repeated to make another string
- Check if a string contains a palindromic sub-string of even length
- Check if a string can be formed from another string using given constraints
- Check whether second string can be formed from characters of first string
- Check if a given string is sum-string
- Check if a string has m consecutive 1's or 0's
- Check if a string is the typed name of the given name
- Check if a string is suffix of another
- Check if given string contains all the digits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.