BackmediumStrings Paytm

Galactic Translator Solution

Problem Statement

Given a string, determine if it can be rearranged into a cyclic sequence of characters based on the pattern where 'k' follows 'j', and all other characters follow alphabetically.

Example 1
Input
abc
Output
false

Explanation: Step-by-step: The string 'abc' cannot be rearranged into a cyclic sequence because 'c' follows 'b' alphabetically, not after 'a'.

Example 2
Input
abcd
Output
true

Explanation: Step-by-step: The string 'abcd' can be rearranged into a cyclic sequence because 'a' follows 'd' alphabetically, but 'b' and 'c' follow 'a' alphabetically as well, and 'd' follows 'c' alphabetically.

Constraints

  • The input string will only contain lowercase letters.
  • The length of the input string will not exceed 500 characters.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free