**Online Coding Round:**

Q.1- A person have N items in his bag with different IDs. The IDs of two items may or may not

be same. He can remove M items from bags then determine the minimum no. of items

present in bag with distinct IDs.

Q.2- Given the length of string (say Len) and maximum number of consecutive vowels that it

can contain. Determine how many unique words that can be generated.

String contains only lower-case letters.

Out of (around) 250 students, only 11 were shortlisted for next round and I was one of them.

**Technical Round Interview:**

First, Interviewer told me to introduce myself, after this he started from oops.

Q.1: what is singleton class and also write the code?

Ans- I explained and wrote the code but it was not fully correct.

https://www.geeksforgeeks.org/singleton-class-java/

Q.2: Difference between overloading and overriding.

Ans- I explained everything properly.

https://www.geeksforgeeks.org/difference-between-method-overloading-and-methodoverriding-in-java/

Q.3: find the output of below program

class Parent {

void method()

System.out.println(“P”);

}

class Child extends Parent {

void method()

System.out.println(“C”);

}

public class GFG {

public static void main(String[] args)

{

Child c=new Parent();

c.method();

}

}

Ans- I said, it will give compilation error, and it was correct.

Q.4: Suppose you have two function having same name and both are present in same class,

then how you will make these both function distinct?

I said by passing different argument in function and he was satisfied too, actually from this

question he wants to know the condition of overloading. He also asked some more concept like

Is it necessary to make the return type of both function same?.etc..

Q.5: He asked 0-1 knapsack problem.

https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/

During this, I was very excited because the question was very easy and I was thinking that I can

write the code of 0-1 knapsack by closing my eyes also but I explained approach for this

problem as I was explaining for above problems, then he told me to write the code for it.

I wrote the recursive code for it and it was correct.

Then he told me to write the dynamic programming code for this, I wrote the half code then he

told, its okk , letâ€™s jump to another question- I said okk sir.

He asked why you have written recursive code first, not dp? I said top-down clicks me first

thatâ€™s why I wrote it first, then he asked many conceptual questions from this like, why to avoid

recursive code, I explained many things like memory uses and stack overflowetc.

Q.6: He made some twist in the above problems, like how you will do the same problems if

you can take the same items as many numbers of times as you want.

I have made only a little change in my previous code (I think I have done this in less than 20

seconds) and it was correct. Then he told me to optimise the space for this problem, as I used 2-

D array in previous problems, then here I used 1-D array. He was very happy with this.

He also asked that on which platform you use to code, I said codechef, then he asked that

have you participated in September long challenge- I said No sir, because I was doing data

structures and algorithms.

He told me that interview time is over, but I want to continue it, are you free? I said yes sir, Iâ€™m

free.

Q.7: He asked me to print the right view of Binary tree.

Here, Again I was excited very much but controlled myself because I have done this problem

many times.

I explained him using HashMap.

Then he told me to do it without space- I have also done it.

Q.8: What is Linked List?

I explained properly with code.

Q.9: how you will find the middle node of linked List?

https://www.geeksforgeeks.org/write-a-c-function-to-print-the-middle-of-the-linkedlist/Here, again excitement was appearing on face.

I explained the approach with two iteration (like in first iteration I will find the length of linked

list and so on…….

After this, I was waiting that he will ask me to do this in single iteration but he was silent, then I

explained my second approach also. After this, he was laughing and I also laugh, then he

jumped to next question.

Q.10: Given two four-digit prime numbers, suppose 1033 and 8179, we need to find the

shortest path from 1033 to 8179 by altering only single digit at a time such that every number

that we get after changing a digit is prime.

https://www.geeksforgeeks.org/shortest-path-reach-one-prime-changing-single-digit-time/

I explained the approach, it was looking that it might be correct, but it was not correct.

He gave me a test-case to dry run, and my code was giving wrong answer for this test case.

He gave me a little hint that see here how I am converting the source prime number to

destination prime number. He converted it in 6 steps.

Then, Sudden I clicked an approach and explained properly using BFS and it was correct.

He asked me to ask some questions, if you have?

I asked some questions related to company.

My Interview were gone around 1 hour 40 minutes.

Finally, out of 11, 6 students were selected for internship and I was one of them.