Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Ernst & Young (EY) interview experience Real time questions & tips from candidates to crack your interview

React developer

Ernst & Young (EY)
upvote
share-icon
3 rounds | 19 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 Months
Topics: HTML, CSS, ReactJS , JavaScript, Redux, OOPS
Tip
Tip

Tip 1 : Do at-least 2 good projects and you must know every bit of them.
Tip 2 : Understand the fundamentals of JavaScript as they are asked very often.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Medium
Video Call
Duration60 Minutes
Interview date27 Sep 2021
Coding problem7

This was a preety intense round revolving mainly around the core concepts of JavaScript . I was confident about my
skills in JavaScript as I already had some projects in JS and I also completed the Guided Path of JS in CodeStudio
which boosted my preparation and helped me crack these Frontend Interviews.

1. Javascript Question

What are callbacks?

Problem approach

A callback is a function that will be executed after another function gets executed.

In javascript, functions are treated as first-class citizens, they can be used as an argument of another function, can be
returned by another function and can be used as a property of an object.

Functions that are used as an argument to another function are called callback functions.


Example Code :

function divideByHalf(sum){
console.log(Math.floor(sum / 2));
}

function multiplyBy2(sum){
console.log(sum * 2);
}

function operationOnSum(num1,num2,operation){
var sum = num1 + num2;
operation(sum);
}
operationOnSum(3, 3, divideByHalf); // Outputs 3
operationOnSum(5, 5, multiplyBy2); // Outputs 20


Explanation :

In the code above, we are performing mathematical operations on the sum of two numbers.

The operationOnSum function takes 3 arguments, first number, second number, and the operation that is to be
performed on their sum (callback) .

Both divideByHalf and multiplyBy2 functions are used as callback functions in the code above.

These callback functions will be executed only after the function operationOnSum is executed.

Therefore, callback is a function that will be executed after another function gets executed.

2. Javascript Question

Explain Hoisting in javascript.

Problem approach

Hoisting is a default behaviour of javascript where all the variable and function declarations are moved on top.
This means that irrespective of where the variables and functions are declared, they are moved on top of the scope.
The scope can be both local and global.


EXAMPLE 1 :

hoistedVariable = 10;
console.log(hoistedVariable); // outputs 10 even when the variable is declared after it is initialized
var hoistedVariable;


EXAMPLE 2 :

hoistedFunction(); // Outputs " Hello world! " even when the function is declared after calling
function hoistedFunction(){
console.log(" Hello world! ");
}


EXAMPLE 3 :

// Hoisting takes place in the local scope as well
function doSomething(){
x = 33;
console.log(x);
var x;
}

3. Javascript Question

What are closures?

Problem approach

A closure is the combination of a function and the lexical environment within which that function was declared. i.e, It is
an inner function that has access to the outer or enclosing function’s variables. The closure has three scope chains

i) Own scope where variables defined between its curly brackets
ii) Outer function’s variables
iii) Global variables

Let's take an example of closure concept,

function Welcome(name){
var greetingInfo = function(message){
console.log(message+' '+name);
}
return greetingInfo;
}
var myFunction = Welcome('John');
myFunction('Welcome '); //Output: Welcome John
myFunction('Hello Mr.'); //output: Hello Mr.John


As per the above code, the inner function(i.e, greetingInfo) has access to the variables in the outer function scope(i.e,
Welcome) even after the outer function has returned.

4. Javascript Question

What is the difference between slice and splice?

Problem approach

Slice :
1) Doesn't modify the original array(immutable)
2) Returns the subset of original array
3) Used to pick the elements from array

Splice : 
1) Modifies the original array(mutable)
2) Returns the deleted elements as array
3) Used to insert or delete elements to/from array

5. Javascript Question

What is a first class function?

Problem approach

In Javascript, functions are first class objects. First-class functions means when functions in that language are treated like any other variable.

For example, in such a language, a function can be passed as an argument to other functions, can be returned by another function and can be assigned as a value to a variable. For example, in the below example, handler functions assigned to a listener

const handler = () => console.log ('This is a click handler function');
document.addEventListener ('click', handler);

6. Javascript Question

Sort an array of integers in JS.

Problem approach

1) The sort() method allows us to sort elements of an array in place. Besides returning the sorted array, the sort()
method changes the positions of the elements in the original array.

2) By default, the sort() method sorts the array elements in ascending order with the smallest value first and largest
value last.

3) The sort() method casts elements to strings and compares the strings lexicographically to determine the orders.
To sort an array of integers in JS :


Code :

let numbers = [0, 1, 20, 3, 30, 2, 10];
numbers.sort((a, b) => a - b);

console.log(numbers); //[0,1,2,3,10,20,30]


The compare() function accepts two arguments a and b. The sort() method will sort elements based on the return
value of the compare() function with the following rules:

i) If compare(a,b) is less than zero, the sort() method sorts a to a lower index than b. In other words, a
will come first.

ii) If compare(a,b) is greater than zero, the sort() method sort b to a lower index than a, i.e., b will come
first.

iii) If compare(a,b) returns zero, the sort() method considers a equals b and leaves their positions
unchanged.

7. Covid Vaccination

Moderate
0/80
Asked in companies
GoogleCurefitMicrosoft

We are suffering from the Second wave of Covid-19. The Government is trying to increase its vaccination drives. Ninja wants to help the Government to plan an effective method to help increase vaccination following safety measures. Time is running out. Can you help the nation?

You are given two positive integers: ‘n,’ ‘maxVaccines’ denoting the number of days for which this vaccination drive will go on and the total number of vaccines available for the drive, respectively. You have to find the number of vaccines administered each day. You are also given a number ‘dayNumber,’ and we are interested to know the maximum number of vaccines that can be administered on ‘dayNumber’ th day.

The rules of the vaccination drive :

1. There should be a positive number of vaccines administered each day during the vaccination drive.

2. The absolute difference between the number of vaccines in two consecutive days should not exceed 1.

3. The sum of all the elements of the vaccines array does not exceed maxVaccines, that is, you cannot administer more vaccines than what is provided to you.

4. Vaccines administered on ‘dayNumber’ th day should be maximized.

Problem approach

Code : 

function binarySearch(arr,value,startPos,endPos){
if(startPos > endPos) return -1;

let middleIndex = Math.floor(startPos+endPos)/2;

if(arr[middleIndex] === value) return middleIndex;

elsif(arr[middleIndex > value]){
return binarySearch(arr,value,startPos,middleIndex-1);
}
else{
return binarySearch(arr,value,middleIndex+1,endPos);
}
}

Try solving now
02
Round
Medium
Video Call
Duration60 Minutes
Interview date27 Sep 2021
Coding problem10

In this round, I was asked questions from React and Redux. Since I already had prior experience in working with React
and Redux , I answered most of the questions correctly and was preety much confident about passing this round.

1. ReactJS Question

What are the differences between a class component and functional component?

Problem approach

Class Components :

1) Class-based Components uses ES6 class syntax. It can make use of the lifecycle methods.
2) Class components extend from React.Component.
3) In here you have to use this keyword to access the props and functions that you declare inside the class
components.


Functional Components :

1) Functional Components are simpler comparing to class-based functions.
2) Functional Components mainly focuses on the UI of the application, not on the behavior.
3) To be more precise these are basically render function in the class component.
4) Functional Components can have state and mimic lifecycle events using React Hooks.

2. ReactJS Question

What are stateless and stateful components?

Problem approach

Stateless Components : If the behaviour is independent of its state then it can be a stateless component. You can use
either a function or a class for creating stateless components. But unless you need to use a lifecycle hook in your
components, you should go for function components.


Stateful Components : If the behaviour of a component is dependent on the state of the component then it can be
termed as stateful component. These stateful components are always class components and have a state that gets
initialized in the constructor.

3. ReactJS Question

What is diffing algorithm?

Problem approach

React needs to use algorithms to find out how to efficiently update the UI to match the most recent tree. The diffing
algorithms is generating the minimum number of operations to transform one tree into another. However, the
algorithms have a complexity in the order of O(n^3) where n is the number of elements in the tree.


In this case, for displaying 1000 elements would require in the order of one billion comparisons. This is far too
expensive. Instead, React implements a heuristic O(n) algorithm based on two assumptions :

1) Two elements of different types will produce different trees.
2) The developer can hint at which child elements may be stable across different renders with a key prop.

4. ReactJS Question

What is reconciliation?

Problem approach

When a component's props or state change, React decides whether an actual DOM update is necessary by
comparing the newly returned element with the previously rendered one. When they are not equal, React will update
the DOM. This process is called reconciliation.

5. ReactJS Question

What are props in React?

Problem approach

The props in React are the inputs to a component of React. They can be single-valued or objects having a set of values that will be passed to components of React during creation by using a naming convention that almost looks similar to HTML-tag attributes. We can say that props are the data passed from a parent component into a child component.

The main purpose of props is to provide different component functionalities such as :

1) Passing custom data to the React component.
2) Using through this.props.reactProp inside render() method of the component.
3) Triggering state changes.


For example, consider we are creating an element with reactProp property as given below: 
This reactProp name will be considered as a property attached to the native props object of React which already exists on each component created with the help of React library: props.reactProp;.

6. Redux Question

What are the advantages of using Redux?

Problem approach

Some of the advantages of using Redux are as follows:

1) Redux provides extremely easy state transfer between the components.

2) The states are always predictable in Redux and its maintenance is relatively easy.

3) Debugging and testing code in Redux is simple through logging behaviour and status.

4) Redux provides great performance. It might occur to us that keeping the application's state global would result in bad performance. However, usually, that is not the case as React Redux implements a lot of performance optimizations internally so that our own connected component only re-renders when it actually needs to.

5) Redux also offers state persistence by storing the application's state to local storage and restoring it after a refresh.

7. Redux Question

Highlight the key differences between mapStateToProps() and mapDispatchToProps()?

Problem approach

mapStateToProps() : 
1) The mapStateToProps() method is used to render the stored data to the component.
2) The entirety of the results of the mapStateToProps() method is a plain object which is later merged into the component’s prop.
3) This method's use is to connect the redux state to the props of the react component.


mapDispatchToProps() : 
1) The mapDispatchToProps() method is used to render the action creators with props to the component.
2) In the mapDispatchToProps() method, each action creator is wrapped in the dispatcher call so that they can be called upon directly and later merged into the component’s prop.
3) This method's use is to connect redux actions to the react props.

8. Redux Question

What is Combine Reducer?

Problem approach

The combineReducers helper function turns an object whose values are different reducing functions into a single
reducing function you can pass to createStore . The resulting reducer calls every child reducer, and gathers their
results into a single state object.

9. Redux Question

How Relay is different from Redux?

Problem approach

Relay is similar to Redux in that they both use a single store. The main difference is that relay only manages state
originated from the server, and all access to the state is used via GraphQL queries (for reading data) and mutations
(for changing data). Relay caches the data for you and optimizes data fetching for you, by fetching only changed data
and nothing more.

10. Redux Question

How can we structure the top level directories in Redux?

Problem approach

Every Redux application has multiple top-level directories as given below :

1) Components: Components are used for “dumb” React components unfamiliar with Redux.

2) Containers: Containers are used for “smart” React components that are connected to Redux.

3) Actions: Actions are used for all the action creators, where the file name should be corresponding to the part of the
app.

4) Reducers: Reducers are used for all the reducers where the file name is corresponding to the state key.

5) Store: Stores are used for store initialization. This directory works best in small and mid-level size apps.

03
Round
Easy
HR Round
Duration30 Minutes
Interview date27 Sep 2021
Coding problem2

This was a Technical Cum HR round where I was first asked some basic principles around Frontend Web Development
and then we discussed about my expectations from the company , learnings and growth in the forthcomig years. I would
suggest be honest and try to communicate your thoughts properly in these type of rounds to maximise your chances of
getting selected.

1. Basic HR Question

Do you know anything about the company ?

Problem approach

General Tip : Before an interview for any company , have a breif insight about the company , what it does , when was
it founded and so on . All these info can be easily acquired from the Company Website itself .

2. Basic HR Question

Why should we hire you?

Problem approach

Tip 1 : The cross questioning can go intense some time, think before you speak.

Tip 2 : Be open minded and answer whatever you are thinking, in these rounds I feel it is important to have opinion.

Tip 3 : Context of questions can be switched, pay attention to the details. It is okay to ask questions in these round,
like what are the projects currently the company is investing, which team you are mentoring. How all is the work
environment etc.

Tip 4 : Since everybody in the interview panel is from tech background, here too you can expect some technical
questions. No coding in most of the cases but some discussions over the design can surely happen.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is the default value of int data type?

Choose another skill to practice
Start a Discussion
Similar interview experiences
company logo
Software Engineer
3 rounds | 5 problems
Interviewed by Ernst & Young (EY)
1048 views
0 comments
0 upvotes
company logo
Senior Analyst
2 rounds | 2 problems
Interviewed by Ernst & Young (EY)
519 views
0 comments
0 upvotes
company logo
SDE - 2
4 rounds | 11 problems
Interviewed by Ernst & Young (EY)
1160 views
0 comments
0 upvotes
company logo
Analyst
3 rounds | 4 problems
Interviewed by Ernst & Young (EY)
550 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
React developer
1 rounds | 5 problems
Interviewed by Infosys
1788 views
0 comments
0 upvotes