Infosys Interview Experience for Specialist Programmer(Lateral)

• Last Updated : 31 Aug, 2021

Round 1: It started with a problem-solving round. I got 30 min to solve.

1. Question:  An evil scientist has developed an injection that induces insatiable hunger in a fish. On giving this injection, a fish of size x can eat another fish of smaller size y (y < x) and become a fish of size x + y retaining this hunger. An aquarium has a number of fishes of various sizes. The scientist introduces an injected fish into this aquarium with an objective that eventually only 1 fish remains. In order to achieve this, the scientist is allowed only two types of moves: either add a normal fish of any size or remove an existing normal fish from the aquarium. Given the sizes of other fishes in the aquarium and the size of injected fish, write a program to determine the minimum number of moves needed by the scientist to achieve his objective. For example, suppose there are 5 fishes in the aquarium, the injected fish is of size 10 and the other fishes are of sizes 9, 20, 25, and 100. To ensure that only 1 fish remains in the aquarium the scientist needs to remove the fish of size 100 and add a fish of size 3. So the output is 2. The sequence of steps is shown below. The sizes of fishes in the aquarium at each step are shown in curly braces. The highlighted number is the size of the injected fish.

Solution:

Javascript

 function fish(x, A) {   A.sort((a,b) => a-b);       let sum = x;   let required_removals=A.length;   let moves = 0;   let best_moves=required_removals;   let i =0;       while(i A[i]) {       sum +=A[i];       required_removals -=1;       i=i+1;     } else {       sum = sum +(sum -1);       moves=moves+1;     }         best_moves = Math.min(best_moves, moves+required_removals);   }       return best_moves;  }      var arr= [   [10, [9,20,25,100]],   [3, [25,20,100,400,500]],   [50, [25,20,9,100]]  ]      for(let [x,A] of arr) {   console.log(`\${x}#\${A}`);   console.log("");   console.log(fish(x,A));  }

After that, I am from MERN stack technology. So, I was been asked a couple of React.js and Node.js Questions

1. Redux Flow, Redux Saga, Thunk, Refs, Lazy Loading in React.js, Formik
2. Wrapper Class in Node.js, ejs, Coa Framework, Express Questions
3. Mongo DB data aggregation

Round 2: Questions mainly from my project and React.js

Round 3: HR Round (Salary and Other Personal Details Discussion)

My Personal Notes arrow_drop_up