SauravSingh3296's blog

By SauravSingh3296, history, 5 hours ago, In English

first of all let me clear the constraints 1 <= T <= 10 , 1 <= N <= 1e5 and 1 <= K <= 26 ; where 'T' is the number of test cases and 'N' is the size of the string .

Q => A string is called beautiful if each character of the string is one of the first K letters of the English lowercase alphabet and that string does not contain any substring of length 2 or more which is a palindrome.

You are given the following: * Two non-negative integers N and K * A beautiful string S of length N

Task:- Determine the lexicographically smallest string of length N which is the beautiful and is lexicographically larger than string S. If no such string exists output will be -1. If multiple answer exist print any of them .

Input : Number of testcase => T Length of string => N The number of alphabets from starting which can be taken => K string => S

example : 2 4 5 eace 3 8 hgf

answers:

eadb -1

Note : I do not remember the time constraint ;

  • Vote: I like it
  • 0
  • Vote: I do not like it