Nagarro Software interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Nagarro Software
upvote
share-icon
2 rounds | 8 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 months
Topics: Data Structures, DBMS , OOPS, System Design, Algorithms, Dynamic Programming.
Tip
Tip

Tip 1 : Practice At least 250 Questions of DSA
Tip 2 : Do hands-one practice of questions
Tip 3 : Practice questions with optimized approaches

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

Tip 1 : Add some good projects to your resume.
Tip 2 : Write only those things in which you are confident.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration240 Minutes
Interview date16 Sep 2021
Coding problem5

Aptitude questions + 3 medium level Coding Problem + 2 hard level Coding problem

1. Clone a Linked List with random pointers

Easy
0/40
Asked in companies
ThalesAmazonQualcomm

You are given a linked list containing 'n' nodes, where every node in the linked list contains two pointers:


(1) ‘next’ which points to the next node in the list

(2) ‘random’ which points to a random node in the list or 'null'.


Your task is to create a 'deep copy' of the given linked list and return its head.


Note:
A 'deep copy' of a linked list means we do not copy the references of the nodes of the original linked list, rather for each node in the original linked list, a new node is created.


Problem approach

1) Create the copy of node 1 and insert it between node 1 & node 2 in original Linked List, create the copy of 2 and insert it between 2 & 3.. Continue in this fashion, add the copy of N after the Nth node 
2) Now copy the arbitrary link in this fashion 


original->next->arbitrary = original->arbitrary->next; /*TRAVERSE 
TWO NODES*/
This works because original->next is nothing but copy of original and Original->arbitrary->next is nothing but copy of arbitrary. 
3) Now restore the original and copy linked lists in this fashion in a single loop. 


original->next = original->next->next;
copy->next = copy->next->next;
4) Make sure that last element of original->next is NULL.

Try solving now

2. Word Ladder

Hard
10m average time
90% success
0/120
Asked in companies
OlaSalesforceDisney + Hotstar

You are given two strings BEGIN and END and an array of strings DICT. Your task is to find the length of the shortest transformation sequence from BEGIN to END such that in every transformation you can change exactly one alphabet and the word formed after each transformation must exist in DICT.

Note:

1. If there is no possible path to change BEGIN to END then just return -1.
2. All the words have the same length and contain only lowercase english alphabets.
3. The beginning word i.e. BEGIN will always be different from the end word i.e. END (BEGIN != END).
Problem approach

The idea to solve the problem is to use BFS. To find the shortest path through BFS, start from the start word and push it in a queue. And once the target is found for the first time, then return that level of BFS traversal. In each step of BFS one can get all the words that can be formed using that many steps. So whenever the target word is found for the first time that will be the length of the shortest chain of words.

Start from the given start word.
Push the word in the queue
Run a loop until the queue is empty
Traverse all words that adjacent (differ by one character) to it and push the word in a queue (for BFS)
Keep doing so until we find the target word or we have traversed all words.

Try solving now

3. Ninja's Gift

Hard
45m average time
55% success
0/120
Asked in companies
MicrosoftNagarro Software

Ninja is going to visit her friend Mico. He is thinking to gift her a string. But he came to know that Mico only likes the string 'S'. Ninja already has a string 'K'. Now, Ninja can change the string 'K' in some other string by choosing any character in one move and change all its occurrence with any other lowercase English character. He can do this several times.

Help Ninja to find if he can change his string 'K' to string 'S', which Mico likes.

Note:
Both 'S' and 'K' contain only lowercase English characters.
For Example:
K = "aabb" and S = "bbcc"
Now Ninja can do the following changes:
- Change ‘b’ to ‘c’ -> “aacc”
- Change ‘a’ to ‘b’ -> “bbcc”

Hence Ninja can give Mico the desired gift.
Try solving now

4. Count all sub-arrays having sum divisible by k

Moderate
15m average time
85% success
0/80
Asked in companies
MicrosoftProtiumIntuit

Given an array ‘ARR’ and an integer ‘K’, your task is to find all the count of all sub-arrays whose sum is divisible by the given integer ‘K’.

Note:
If there exists no subarray in the given sequence whose sum is divisible by ‘K’ then simply return ‘0’.
Example:
Suppose the given array is ‘ARR’ = { 5, 0, 2, 3, 1} and ‘K = 5’.
As we can see in below image, there are a total of 6 subarrays that have the total sum divisible by ‘K’
So we return the integer 6.

subsequence

Problem approach

We can solve this problem by computing modulo of array numbers with K. if sum of two numbers is divisible by K, then if one of them gives remainder i, other will give remainder (K – i). First we store frequencies of numbers giving specific remainder in a frequency array of size K. Then we loop for all remainders i and include max(f[i], f[K – i]). Why? a subset with no pair sum divisible by K must include either elements with remainder f[i] or with remainder f[K – i]. Since we want to maximize the size of subset, we pick maximum of two sizes.
In below code array numbers with remainder 0 and remainder K/2 are handled separately. If we include more than 2 numbers with remainder 0 then their sum will be divisible by K, so we have taken at max 1 number in our consideration, same is the case with array numbers giving remainder K/2.

Try solving now

5. Allocate Books

Hard
0/120
Asked in companies
ZSArcesiumAdobe

You are the Librarian of the Ninja library. There are ‘N’ books available in the library and ‘B’ ninjas want to read the books. You know the number of pages in each book and you have to allocate the books to the ‘B’ ninjas in such a way that the maximum number of pages allocated to a ninja is minimum.

Note

A book will be allocated to exactly one ninja. 
At least one book has to be allocated to a ninja.
Allotment of the books should be done in a contiguous manner. For example, a ninja can not be allocated book 2 and book 4, skipping book 3.

The task is to return the minimum of the maximum number of pages allocated to a ninja.

Problem approach

The idea is to use Binary Search. We fix a value for the number of pages as mid of current minimum and maximum. We initialize minimum and maximum as 0 and sum-of-all-pages respectively. If a current mid can be a solution, then we search on the lower half, else we search in higher half.
Now the question arises, how to check if a mid value is feasible or not? Basically, we need to check if we can assign pages to all students in a way that the maximum number doesn’t exceed current value. To do this, we sequentially assign pages to every student while the current number of assigned pages doesn’t exceed the value. In this process, if the number of students becomes more than m, then the solution is not feasible. Else feasible.
Below is an implementation of above idea.

Try solving now
02
Round
Easy
Face to Face
Duration30 minutes
Interview date24 Sep 2021
Coding problem3

The interview was more focused on DSA and time complexity questions. They gave me 5 coding questions and ask me the time complexity. some other questions were there based on DBMS.
3 coding questions were given to me to solve

1. Remove 9

Easy
15m average time
85% success
0/40
Asked in companies
DunzoCitrixCrowe

A committee of mathematicians decided to remove every natural number which contains digit 9 such as 9, 19, 29, ... . Hence the new sequence of natural numbers will be: 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, ….

Given the natural number ‘N’, can you find the ‘N’th number in the new sequence formed after removing every integer that contains 9?

Note:

The sequence of natural numbers are integers that start from 1.
Problem approach

The simplest approach to solve the above problem is to iterate up to N and keep excluding all numbers less than N containing the digit 9. Finally, print the Nth natural number obtained.

Follow below steps below to solve the problems : 

Initialize one variable count = 0
and use for loop and pass the element of loop to isDigitNine(i) function to check whether that number contains 9 or not and increment that if not present 
And once count hit N assign the last i to to count and break the loop.
Return answer as count

Try solving now

2. Placment Of students

Moderate
15m average time
90% success
0/80
Asked in companies
SamsungNagarro Software

The coordinator of the placement cell has received many applications of students applying in different companies. There are M students and N companies who are offering jobs. Each student is interested in a particular number of companies for a job. Each job opening can only accept one student and a student can only have 1 job. As a placement coordinator, you want to place a maximum number of students.

Your task is to find the maximum number of students that can be placed in one of their desired jobs

The data about the set of favourable jobs are given in the form of an M * N binary matrix named ‘mat’, i.e for M students we have M rows each having N integers. Now for example if the first candidate is interested in job1 the value of mat[i][j] will be 1 otherwise it will be 0.

Note:
It is possible that a single candidate is interested in multiple jobs but he can take up only one of the job out of his favourable jobs, also there is no priority in jobs, i.e all favourable jobs are equally favourable to the candidate
Problem approach

We generate n! possible job assignments and for each such assignment, we compute its total cost and return the less expensive assignment. Since the solution is a permutation of the n jobs, its complexity is O(n!).

Try solving now

3. Coin game winner where every player has three choices

Moderate
25m average time
75% success
0/80
Asked in companies
OlaNagarro Software

Two players 'X' and 'Y', are playing a coin game. Initially, there are 'N' coins. Each player can pick exactly 'A' coins or 'B' coins or 1 coin. A player loses the game if he is not able to pick any coins. 'X' always starts the game, and each player plays optimally. You are supposed to find which player wins the coin game.

Problem approach

The idea is to use a dynamic programming paradigm, and see who wins the game. ‘X’ start’s the game and has 3 options, to choose ‘A’ or ‘B’ or 1 coin. Similarly, ‘Y’ makes a move and so on. The player who is not able to move further loses the coin game. We solve in a bottom-up manner from 0 to 'NO_OF_COINS' coins and calculate our ans.

Let’s say if we have some i coins, and Player ‘X’ is playing the game, ‘X’ will always try to reach a point from where ‘Y’ cannot win. So, we are checking all three options, we can reach a point from where the other player cannot win we return true otherwise we return false.



The algorithm is as follows :

Declare a boolean array ‘DP’, where DP[i] stores the player starting with ‘i’ coins wins the game or not, if the player starting with ‘i’ coins wins it stores true, otherwise false.
Set, DP[0] to false.
Set, DP[1] to true.
Iterate from ‘i’ = 2 to ‘N’,
Set, DP[i] to ans to true if DP[i - 1] is false.
If ‘i’ >= ‘A’, set DP[i] to true if DP[i - A] is false.
If ‘i’ >= ‘B’, set DP[i] to true if DP[i - B] is false.
Return, DP[N].

Try solving now

Here's your problem of the day

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

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 3 problems
Interviewed by Nagarro Software
0 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Nagarro Software
937 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by Nagarro Software
1222 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by Nagarro Software
758 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
115097 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
58238 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
35147 views
7 comments
0 upvotes