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

SDE - 1

Nagarro Software
upvote
share-icon
3 rounds | 9 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 Months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

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
Online Coding Interview
Duration150 Minutes
Interview date9 Sep 2020
Coding problem3

It was an Aptitude test and Technical objective test of 60 minutes followed by a Coding test of 90 minutes.There was a 1 hour gap b/w the two tests.

1. Count derangements

Moderate
35m average time
60% success
0/80
Asked in companies
AmazonInfo Edge India (Naukri.com)OLX Group

A Derangement is a permutation of ‘N’ elements, such that no element appears in its original position. For example, an instance of derangement of {0, 1, 2, 3} is {2, 3, 1, 0}, because 2 present at index 0 is not at its initial position which is 2 and similarly for other elements of the sequence.

Given a number ‘N’, find the total number of derangements possible of a set of 'N’ elements.

Note:
The answer could be very large, output answer %(10 ^ 9 + 7).
Problem approach

Approach : 
1) In the bottom-up approach, extra space is used to store subproblems. However, we only need two previous values to calculate the count of derangements of the current value of ‘N’.
2) Instead of storing in an array, two variables are used to store the two previous values.
3) Initialize two variables, ‘prevOne’ and ‘prevTwo’ to 0 and 1 respectively.
4) Run a loop where ‘i’ ranges from 3 to ‘N’.
5) Find the count of derangements for the current value of ‘i’ using ‘CUR’ = ('i' - 1) * ('prevOne' + ‘prevTwo’).
6) Store the value of ‘prevOne’ in ‘prevTwo’ and the value of ‘CUR’ in ‘prevOne’.
7) Return ‘prevTwo’ which stores the total number of derangements of ‘N’ elements.

TC : O(N), where N=number of elements
SC : O(1)

Try solving now

2. Find prime numbers

Easy
15m average time
80% success
0/40
Asked in companies
HSBCOptumIBM

You are given a positive integer ‘N’. Your task is to print all prime numbers less than or equal to N.

Note: A prime number is a natural number that is divisible only by 1 and itself. Example - 2, 3, 17, etc.

You can assume that the value of N will always be greater than 1. So, the answer will always exist.

Problem approach

Approach (Using Sieve of Eratosthenes) :

1) First, we will make a boolean array/list isPrime of size N + 1. This will mark if a number is prime or not. Initially, all values will be true.

2) Then, we initialize a variable num equal to 2 which represents the current processing prime number.

3) We will loop as num from 2 to N^½:
3.1) If num is not prime, we continue.
3.2) Else, we will mark all multiples of num in isPrime as false.

4) In the end, we will iterate through isPrime and store all primes in the result vector/list.

5) Finally, we return the result vector.

TC : O(N * log(log N)), where N is the given positive integer. 
SC : O(N)

Try solving now

3. Common Elements

Moderate
35m average time
70% success
0/80
Asked in companies
SAP LabsWalmartFlipkart limited

Given two 1-dimensional arrays containing strings of lowercase alphabets, print the elements that are common in both the arrays i.e. the strings that are present in both the arrays.

Note:
An element of one array can be mapped only to one element of the array. For example :

Array 1 = {“ab”, “dc”, “ab”, “ab”}
Array 2 = {“dc”, “ab”, “ab”} 

The common elements for the above example will be “dc”, “ab”, and “ab”. 
Problem approach

Approach (Using Trie) : 

1) Add a additional field “COUNT” in the implementation of the node of the trie. This field will be equal to the number / occurrences of the current string in the first array. For the nodes that do not represent the end of a string, the value of count will be zero.

2) Firstly, we traverse the first array and insert the strings in a trie. While inserting a string in the trie, we increment the variable “COUNT” of the last node i.e. the node representing the last character of the string.

3) After the creation of the trie, we traverse the second array and for each string in the second array, we check if it is present in the trie. 

4) If the string exists in the trie, we add it to the answer and decrement the variable “COUNT” for the last node i.e. the node representing the last character of the string.

5) After the traversal of the second array, the answer will contain the common strings.

TC : O(K * S), where ‘K’ = max('N', ‘M’) and ‘S’ is the average length of strings.
SC : O(26 * N * S), where ‘N’ is the size of the first array and ‘S’ is the average length of the strings.

Try solving now
02
Round
Medium
Video Call
Duration60 Minutes
Interview date10 Sep 2020
Coding problem4

This round had 1 question from DSA particulary Trees and after that some questions from OOPS were asked.

1. Spiral Order Traversal of a Binary Tree

Easy
20m average time
75% success
0/40
Asked in companies
PayUAtlassianAmazon

You have been given a binary tree of 'N' nodes. Print the Spiral Order traversal of this binary tree.

For example
For the given binary tree [1, 2, 3, -1, -1, 4, 5, -1, -1, -1, -1]
    1
   / \
  2   3
     / \
    4   5

Output: 1 3 2 4 5
Problem approach

Approach : 

1) We will maintain two stacks, one for each direction i.e. leftToRight and rightToleft.

2) We will do a level order traversal of the given binary tree and push nodes of each level onto one of the stack according to the current direction of traversal.

3) After we’ve pushed all nodes of a level onto one stack, we’ll start popping those nodes. While popping the nodes we will push their children (if any) onto our other direction stack, so that the next level be traversed in reverse order.

TC : O(N), where N=number of nodes in the binary tree
SC : O(N)

Try solving now

2. OOPS Question

What is the difference b/w Abstract Class and Interface in Java?

Problem approach

Abstract class and interface both are used to achieve abstraction where we can declare the abstract methods.

Key differences b/w Abstract Class and Interface are :

1) Abstract class can have abstract and non-abstract methods.
Interface can have only abstract methods. Since Java 8, it can have default and static methods also.

2) Abstract class doesn't support multiple inheritance.
Interface supports multiple inheritance.

3) Abstract class can have final, non-final, static and non-static variables.
Interface has only static and final variables.

4) Abstract class can provide the implementation of interface.
Interface can't provide the implementation of abstract class.

5) The abstract keyword is used to declare abstract class.
The interface keyword is used to declare interface.

6) An abstract class can extend another Java class and implement multiple Java interfaces.
An interface can extend another Java interface only.

7) An abstract class can be extended using keyword "extends".
An interface can be implemented using keyword "implements".

3. OOPS Question

What is the static keyword in Java?

Problem approach

1) The static keyword in Java is mainly used for memory management. 
2) The static keyword in Java is used to share the same variable or method of a given class. 
3) The users can apply static keywords with variables, methods, blocks, and nested classes. 
4) The static keyword belongs to the class than an instance of the class. 
5) The static keyword is used for a constant variable or a method that is the same for every instance of a class.

4. OOPS Question

Difference between Constructor and Method?

Problem approach

Constructors :
1) A Constructor is a block of code that initializes a newly created object.
2) A Constructor can be used to initialize an object.
3) A Constructor is invoked implicitly by the system
4) A Constructor is invoked when a object is created using the keyword new.
5) A Constructor doesn’t have a return type.
6) A Constructor’s name must be same as the name of the class.
7) A Constructor cannot be inherited by subclasses.


Method :
1) A Method is a collection of statements which returns a value upon its execution.
2) A Method consists of Java/C++ code to be executed.
3) A Method is invoked by the programmer.
4) A Method is invoked through method calls.
5) A Method must have a return type.
6) A Method’s name can be anything.
7) A Method can be inherited by subclasses.

03
Round
Medium
Video Call
Duration60 minutes
Interview date10 Sep 2020
Coding problem2

This round had 2 questions from DSA and after that some basic HR questions were asked.

1. Ways To Make Coin Change

Moderate
20m average time
80% success
0/80
Asked in companies
MicrosoftHSBCOracle

You are given an infinite supply of coins of each of denominations D = {D0, D1, D2, D3, ...... Dn-1}. You need to figure out the total number of ways W, in which you can make a change for value V using coins of denominations from D. Print 0, if a change isn't possible.

Problem approach

This was a very standard DP problem and I had already solved it on platforms like LeetCode and CodeStudio so I was able to come up with the logic and code it preety fast.

Steps :
1) Create a two-dimensional array, ‘dp’, where ‘dp[i][j]’ will denote the total number of ways to make j value by using i coins.

2) Run 2 loops ,1st one from 1 to value and second one throught the array denominations.

3) Fill dp array by the recurrence relation as follows:
ways[i][j] = ways[i-1][j] + ways[i][j-denominations[i]] (if j-denominations[i]>=0)
Where first term represents that we have excluded that coin and,
Second term represents that we have included that coin.

4) Base Case : Fill dp[0]=0 (as we can make 0 amount by giving no coins at all) and the remaining indices with INT_MAX value

5) Finally , if dp[value]==INT_MAX , return -1 as it is not possible to make "value" using the given coins else return dp[value] itself

TC : O(N*V) where N=number of coins and V=Value to be made
SC : O(N*V)

Try solving now

2. Check If The String Is A Palindrome

Easy
10m average time
90% success
0/40
Asked in companies
IntuitSprinklrCIS - Cyber Infrastructure

You are given a string 'S'. Your task is to check whether the string is palindrome or not. For checking palindrome, consider alphabets and numbers only and ignore the symbols and whitespaces.

Note :

String 'S' is NOT case sensitive.

Example :

Let S = “c1 O$d@eeD o1c”.
If we ignore the special characters, whitespaces and convert all uppercase letters to lowercase, we get S = “c1odeedo1c”, which is a palindrome. Hence, the given string is also a palindrome.
Problem approach

Approach 1 :
1) Initialise a string named rev with the given string .
2) Reverse the string rev.
3) Now, if s is a palindrome then we would have rev==s , return true if rev==s and false otherwise

TC : O(N) where N=length of the string
SC : O(1)


Approach 2(Using Two Pointers) :
1) Keep pointer i=0 and j=n-1 where n=length of the string
2) Run a loop till i<=j and check if s[i]==s[j] for the condition of palindrome
3) If at any point s[i]!=s[j] then simply return false from the loop
4) Else return true after the end of the loop.

TC : O(N)
SC : O(1)

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