Searching 2


Manna is extremely disappointed to find out that no one in his college knows his first name. Even his classmates call him only by his last name. Frustrated, he decides to make his fellow college students know his first name by forcing them to solve this question.\n\nYou are given a long string as input in each testcase, containing any ASCII character. Your task is to find out the number of times SUVO and SUVOJIT appears in it.\n\nInput Format\nThe first line contains the number of test cases, T. Next, T lines follow each containing a long string S.\n \nOutput Format\nFor each long string S, display the no. of times SUVO and SUVOJIT appears in it.


import java.util.*;
class TestClass {
    public static void main(String args[] ) throws Exception {
        Scanner scan = new Scanner(;
        int testCase = scan.nextInt();
            char[] arr =;
            int suvo = 0;
            int jit = 0;
            for(int i = 0;i<arr.length-3;i++){
                if(arr[i] == 'S' && arr[i+1] == 'U' && arr[i+2] == 'V' && arr[i+3] == 'O'){
                        if(arr[i+4] == 'J' && arr[i+5] == 'I' && arr[i+6] == 'T'){
            System.out.println("SUVO = " + suvo + ", SUVOJIT = "+jit);
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock