Open In App

Mitsogo Intreview Experience for Developer role Kochi/ Chennai

They asked me to code two pattern questions live in the face-to-face interview round which is 3rd round, The questions in the 2nd round were difficult and it was online.

1:

[


[


[


[]


]


]

/*package whatever //do not write package name here */

public class BracketPattern {
    public static void main(String[] args) {
       int num =4;
       for(int i =0;i< 7 ;i++) {
           if(i==3) {
               for(int j =0;j<=7;j++){
                   if(j<6) {
                       System.out.print("  ");
                   } else if(j==6) {
                       System.out.print("["); 
                   } else if(j==7) {
                       System.out.print("]"); 
                   }
               } 
               System.out.println();
               System.out.println();
           }
           if(i>=4) {
               for(int j =0;j<=num;j++) {
               if(j<num) {
                System.out.print("  ");  
               } else {
                System.out.print("]");   
               }
           }
           System.out.println();
           System.out.println();
           num-=2;
           }
           if(i<3) {
           for(int j =0;j<=i;j++) {
               if(j<i) {
                System.out.print("    ");  
               } else {
                System.out.print("[");   
               }
           }
           System.out.println();
           System.out.println();
           }
       }
    }
}

Output
[

    [

        [

            []

        ]

    ]

]


2nd. :

1 2 3 4 5

2 2 3 4 5

3 3 3 4 5

4 4 4 4 5

5 5 5 5 5


I had 45 mins to solve both, since I could solve only 1 in the given time I wasn't selected

Article Tags :