Strong Language (SSCRIPT) Solution — Codechef April Long Challenge

Anubhav Mishra
2 min readApr 12, 2021


Problem Statement

A string is said to be using strong language if it contains at least K consecutive characters ‘*’.

You are given a string S with length N. Determine whether it uses strong language or not.


  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first line of each test case contains two space-separated integers N and K.
  • The second line contains a single string S with length N.


Print a single line containing the string "YES" if the string contains strong language or "NO" if it does not (without quotes).

You may print each character of each string in uppercase or lowercase (for example, the strings “yEs”, “yes”, “Yes” and “YES” will all be treated as identical).


  • 1≤T≤10
  • 1≤K≤N≤10⁶
  • S contains only lowercase English letters and characters ‘*’
  • Sum of N over all testcases is atmost 10⁶.


Subtask #1 (30 points): N≤10⁴, Sum of Nover all testcases is atmost 10⁴

Subtask #2 (70 points): original constraints

Example Input

5 2
5 2
5 1

Example Output



Example case 1: Since there are no two consecutive characters ‘*’, the string does not contain strong language.

Example case 2: There are two adjacent characters ‘*’, so the string contains strong language.

Example case 3: Since there are no characters ‘*’ in the string, it does not contain strong language.

Code (Solution)

The code has been implemented in Java

/* package codechef; // don't place package name! */import java.util.*;import java.lang.*;import*;/* Name of the class has to be "Main" only if the class is public. */class Codechef{public static void main (String[] args) throws java.lang.Exception{Scanner sc = new Scanner(;int t = sc.nextInt();while(t-- > 0){int n = sc.nextInt();int k = sc.nextInt();sc.nextLine();String str =;int count=0,cnti=0;for(int i=0;i<n;i++){if(str.charAt(i)=='*'){count++;if(count==k){System.out.println("YES");cnti++;break;}}elsecount =0;}if(cnti == 0)System.out.println("NO");}}}

Hope you would have liked the article. Please give 50 claps to this article and follow me for more future programming related blogs.




Anubhav Mishra

Software Engineer , Having my degree B.Tech in Information Technology from BVCOE, New Delhi. Love new Technologies. Electronic Dance Music is love.