Add office photos
Engaged Employer

Nagarro

4.1
based on 3.9k Reviews
Filter interviews by

400+ Interview Questions and Answers

Updated 9 Oct 2024
Popular Designations

Q1. Crazy Numbers Ninja loves playing with numbers. So one day, he wants to arrange a few numbers in the ‘N’ number of rows. The first row contains 1 number, the second row has two numbers, the third row has 3 digi...

read more

Q2. Compress the String Ninja has been given a program to do basic string compression. For a character that is consecutively repeated more than once, he needs to replace the consecutive duplicate occurrences with t...

read more

Q3. Ninja And The New Year Guests Ninja has organized the new year party and invited all the programmers for it, as being the programmer also has been invited by Ninja. To detect whether the guest is a programmer o...

read more

Q4. Write a program: two input, one is N(any integer, lets say 3), second input will be array of integers(duplicate/multiple occurrences of same integer, lets say [2,3,2,4,2] ). You have to return the number whose ...

read more
Ans.
Program to find the number whose occurrence is greater than N/2 in an array of integers. Take two inputs, one integer N and an array of integers. Loop through the array and count the occurrence of each number. Return the number whose occurrence is greater than N/2. If no such number found, return '-1'.
Discover null interview dos and don'ts from real experiences
Asked in
CSD Interview

Q5. Swap Kth Elements Given an array ‘ARR’ of size ‘N,’ swap the Kth element from beginning with the Kth element from the end. For example: If ‘N’ = 5 and K = 2 [1, 2, 3, 4, 5] Then the output will be [1, 4, 3, 2, ...

read more

Q6. Maximum Subarray Sum You are given an array (ARR) of length N, consisting of integers. You have to find the sum of the subarray (including empty subarray) having maximum sum among all subarrays. A subarray is a...

read more
Are these interview questions helpful?

Q7. Maximum meetings You are given the schedule of N meetings with their start time Start[i] and end time End[i]. But you have only 1 meeting room. So, you need to tell the meeting numbers you can organize in the g...

read more

Q8. Fibonacci Member Given a number N, figure out if it is a member of fibonacci series or not. Return true if the number is member of fibonacci series else false. Fibonacci Series is defined by the recurrence F(n)...

read more
Share interview questions and help millions of jobseekers 🌟

Q9. Ways To Make Coin Change 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 f...

read more

Q10. Longest Increasing Subsequence For a given array with N elements, you need to find the length of the longest subsequence from the array such that all the elements of the subsequence are sorted in strictly incre...

read more

Q11. Coin game winner where every player has three choices 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 lo...

read more

Q12. Next Permutation You have been given a permutation of ‘N’ integers. A sequence of ‘N’ integers is called a permutation if it contains all integers from 1 to ‘N’ exactly once. Your task is to rearrange the numbe...

read more

Q13. Sort An Array of 0s, 1s and 2s You have been given an array/list ARR consisting of ‘N’ elements. Each element in the array is either 0, 1 or 2. Now, your task is to sort this array/list in increasing order. For...

read more

Q14. Pairs with difference K You are given with an array of integers and an integer K. You have to find and print the count of all such pairs which have difference K. Note: Take absolute difference between the eleme...

read more

Q15. Find Duplicates In Array You are given an array/list 'ARR' consisting of N integers, which contains elements only in the range 0 to N - 1. Some of the elements may be repeated in 'ARR'. Your task is to find all...

read more

Q16. Count Ways To Reach The N-th Stairs You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two steps. You ar...

read more

Q17. Trapping Rain Water You have been given a long type array/list 'ARR' of size 'N'. It represents an elevation map wherein 'ARR[i]' denotes the elevation of the 'ith' bar. Print the total amount of rainwater that...

read more

Q18. Digits Decoding A few days back, Ninja encountered a string containing characters from ‘A’ to ‘Z’ which indicated a secret message. For security purposes he encoded each character of the string to its numeric v...

read more

Q19. Closest Perfect Square You are given a positive integer ‘N’. You are required to print the perfect square number closest to the ‘N’ and the number of steps required to reach that number. For Example: N = 21 The...

read more

Q20. Longest Palindromic Substring Given a string ’S’ consisting of lower case English letters, you are supposed to return the longest palindromic substring of ‘S’. Note that in case of more than one longest palindr...

read more

Q21. Find Nth Prime You are given a number 'N'. Your task is to find Nth prime number. A prime number is a number greater than 1 that is not a product of two smaller natural numbers. Prime numbers have only two fact...

read more

Q22. Missing Number Given an array ‘ARR’ of ‘N’ integers, where all the elements occur an even number of times and only one number occurs an odd number of times. Find the number which occurs an odd number of times. ...

read more

Q23. Nearest numbers with the same number of set bits Given a positive integer ‘n’, your task is to find the next smallest integer and the previous largest integer having the exact number of ‘1’ bits set in their bi...

read more

Q24. Complete String Ninja developed a love for arrays and strings so this time his teacher gave him an array of strings, ‘A’ of size ‘N’. Each element of this array is a string. The teacher taught Ninja about prefi...

read more

Q25. Check If The String Is A Palindrome 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...

read more

Q26. Equilibrium Index You are given an array Arr consisting of N integers. You need to find the equilibrium index of the array. An index is considered as an equilibrium index if the sum of elements of the array to ...

read more

Q27. Valid Parentheses You're given string ‘STR’ consisting solely of “{“, “}”, “(“, “)”, “[“ and “]” . Determine whether the parentheses are balanced. Input Format: The first line contains an Integer 'T' which deno...

read more

Q28. Second largest element in the array A few days back, Ninja encountered a string containing characters from ‘A’ to ‘Z’ which indicated a secret message. For security purposes he encoded each character of the str...

read more

Q29. 0 1 Knapsack A thief is robbing a store and can carry a maximum weight of ‘W’ into his knapsack. There are 'N' items available in the store and the weight and value of each item is known to the thief. Consideri...

read more

Q30. K - Sum Path In A Binary Tree You are given a binary tree in which each node contains an integer value and a number ‘K’. Your task is to print every path of the binary tree with the sum of nodes in the path as ...

read more

Q31. Convert Sentence You are given a sentence in the form of a string ‘S’. You have to convert ‘S’ into its equivalent mobile numeric keypad sequence, i.e. print the sequence in such a way that if it is typed on th...

read more

Q32. Find prime numbers 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...

read more
Asked in
SDE Interview

Q33. Puzzle Question How do we measure forty-five minutes using two identical wires, each of which takes an hour to burn? We have matchsticks with us. The wires burn non-uniformly. So, for example, the two halves of...

read more

Q34. K subsets with equal sum You are given an array of integers "ARR" of length 'N' and an integer 'K'. Your task is to find whether or not you can divide the array "ARR" into 'K' subsets with equal sum. A subset o...

read more

Q35. Subsequences of String You are given a string 'STR' containing lowercase English letters from a to z inclusive. Your task is to find all non-empty possible subsequences of 'STR'. A Subsequence of a string is th...

read more
Asked in
CSD Interview

Q36. Count derangements 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 prese...

read more

Q37. 0 1 Knapsack A thief is robbing a store and can carry a maximal weight of W into his knapsack. There are N items and the ith item weighs wi and is of value vi. Considering the constraints of the maximum weight ...

read more

Q38. Move All Negative Numbers To Beginning And Positive To End You are given an array 'ARR' consisting of 'N' integers. You need to rearrange the array elements such that all negative numbers appear before all posi...

read more

Q39. Common Elements 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 ele...

read more

Q40. Count characters Write a program to count and print the total number of characters (lowercase english alphabets only), digits (0 to 9) and white spaces (single space, tab i.e. '\t' and newline i.e. '\n') entere...

read more

Q41. N-th Term Of GP You are given the first term (A), the common ratio (R) and an integer N. Your task is to find the Nth term of the GP series. The general form of a GP(Geometric Progression) series is A, A (R), A...

read more

Q42. K Sum Subset You are given an array ‘arr’ of size ‘N’ and an integer ‘K’. Your task is to find the maximum subset-sum of the array that is not greater than ‘K’. For Example: Your are given ‘arr’ = [1, 3, 5, 9],...

read more

Q43. Trailing Zeros in Factorial You are given an integer N, you need to find the number of trailing zeroes in N! (N factorial). Note: 1. Trailing zeros in a number can be defined as the number of continuous suffix ...

read more

Q44. Letter Combinations of a Phone Number Given a string S containing digits from 2 to 9 inclusive. Your task is to find all possible letter combinations that the number could represent. A mapping from Digits to Le...

read more

Q45. Minimum Number of Platform Needed You are given the arrival and departure times of N trains at a railway station in a day. You need to find the minimum of platforms required for the railway station such that no...

read more

Q46. Two Sum You are given an array of integers 'ARR' of length 'N' and an integer Target. Your task is to return all pairs of elements such that they add up to Target. Note: We cannot use the element at a given ind...

read more

Q47. Pair Sum You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to return the list of all pairs of elements such that each sum of elements of each pair equals 'S'. Note: Each pair sho...

read more
Asked in
CSD Interview

Q48. Second largest element in the array You have been given an array/list 'ARR' of integers. Your task is to find the second largest element present in the 'ARR'. Note: a) Duplicate elements may be present. b) If n...

read more

Q49. Validate BST Given a binary tree with N number of nodes, check if that input tree is BST (Binary Search Tree) or not. If yes, return true, return false otherwise. A binary search tree (BST) is a binary tree dat...

read more
Asked in
SDE Interview

Q50. Partition to K equal sum subsets You are given an array of 'N' integers, and a positive integer 'K'. You need to determine if it is possible to divide the array into 'K' non-empty subsets such that the sum of e...

read more

Q51. First non repeating character Ninja is now bored with numbers and is now playing with characters but hates when he gets repeated characters. Ninja is provided a string, and he wants to return the first unique c...

read more
Asked in
SDE Interview

Q52. Sort A “K” Sorted Doubly Linked List You’re given a doubly-linked list with N nodes, where each node deviates at max K position from its position in the sorted list. Your task is to sort this given doubly linke...

read more

Q53. Reverse Alternate K nodes You are given a Singly Linked List of integers and a positive integer 'K'. Modify the linked list by reversing every alternate 'K' nodes of the linked list. A singly linked list is a t...

read more

Q54. Convert String You are given a string 'STR'. You have to convert the first alphabet of each word in a string to UPPER CASE. For example: If the given string 'STR' = ”I am a student of the third year” so you hav...

read more

Q55. Print All Paths You are given a graph with ‘N’ nodes and ‘M’ unidirectional edges. Also you are given two integers ‘S’ and ‘D’ denoting the source and destination. Your task is to find all the paths from ‘S’ t...

read more

Q56. Maximum Path Sum Between Two Leaves You are given a non-empty binary tree where each node has a non-negative integer value. Return the maximum possible sum of path between any two leaves of the given tree. The ...

read more

Q57. Selling Stock You have been given stock values/prices for N number of days. Every i-th day signifies the price of a stock on that day. Your task is to find the maximum profit which you can make by buying and se...

read more

Q58. Word Break You are given a list of “N” strings A. Your task is to check whether you can form a given target string using a combination of one or more strings of A. Note : You can use any string of A multiple ti...

read more

Q59. Check If One String Is A Rotation Of Another String You are given two Strings 'P' and 'Q' of equal length. Your task is to check whether String 'P' can be converted into String 'Q' by cyclically rotating it to ...

read more
Asked in
SDE Interview

Q60. Merge k sorted lists Given 'K' sorted linked lists, each list is sorted in increasing order. You need to merge all these lists into one single sorted list. You need to return the head of the final linked list. ...

read more

Q61. Zigzag Binary Tree Traversal Given a binary tree, return the zigzag level order traversal of the nodes' values of the given tree. Zigzag traversal means starting from left to right, then right to left for the n...

read more

Q62. Find Number Of Islands You are given a 2-dimensional array/list having N rows and M columns, which is filled with ones(1) and zeroes(0). 1 signifies land, and 0 signifies water. A cell is said to be connected t...

read more

Q63. Remove String You have been given a linked list where each node has a single character. You have also been given a string 'STR'. You have to remove all the occurrences of string STR from the linked list. Note: ...

read more

Q64. Most Frequent Word You are given two strings 'A' and 'B' of words. Your task is to find out the most frequent and lexicographically smallest word in string 'A', which is not present in string 'B'. If no such wo...

read more

Q65. Puzzle How do we measure forty-five minutes using two identical wires, each of which takes an hour to burn? We have matchsticks with us. The wires burn non-uniformly. So, for example, the two halves of wire mig...

read more

Q66. This is for Mainframe Dev. how would you sort two unsorted ps files into three different ps files having unique records of both the files in different files and common records in one. explain the steps.

Ans.
Sort two unsorted PS files into three different PS files with unique and common records. Use SORT utility to sort the two input files individually. Use JOINKEYS to join the two sorted files on a common key. Use OUTFIL to direct the output to three different files based on the record type. Ensure that the output files have unique records and common records as required.

Q67. Guess The Number You are given an integer ‘N’ and there is a hidden number in the range [0, N] which you have to guess. You are also given a function higherLower(k) to help you in guessing the number. The ‘high...

read more

Q68. Detect and Remove Loop Given a singly linked list, you have to detect the loop and remove the loop from the linked list, if present. You have to make changes in the given linked list itself and return the updat...

read more

Q69. Trapping Rainwater You have been given a long type array/list 'ARR' of size 'N'. It represents an elevation map wherein 'ARR[i]' denotes the elevation of the 'ith' bar. Print the total amount of rainwater that ...

read more

Q70. Merge Sort Linked List You are given a Singly Linked List of integers. Sort the Linked List using merge sort. Merge Sort is a Divide and Conquer algorithm. It divides the input into two halves, calls itself for...

read more

Q71. Left and Right Rotation of a String You are given a string 'str' and an integer 'D'. Your task is to rotate the given string left (anticlockwise) and right (clockwise) by 'D' units from the starting index. You ...

read more

Q72. Reverse Linked List You are given a Singly Linked List of integers. You need to reverse the Linked List by changing the links between nodes. Input Format : The first line of input contains a single integer T, r...

read more

Q73. Minimum steps to reach target by a Knight You have been given a square chessboard of size ‘N x N’. The position coordinates of the Knight and the position coordinates of the target are also given. Your task is ...

read more

Q74. Count Palindrome Words in A String You are given a string S of words. Your task is to find the number of palindrome words in the given string S. A word is called palindrome, if it reads the same backwards as fo...

read more

Q75. Preorder Traversal You are given the root node of a binary tree consisting of ‘N’ nodes. Your task is to return its preorder traversal. The preorder traversal of a binary tree is defined as a process of travers...

read more
Asked in
SDE Interview

Q76. Duplicate Subtrees You have been given a binary tree, you are supposed to return the root values of all the duplicate subtrees. For each duplicate subtree, you only need to return the root value of any one of t...

read more

Q77. Check If Binary Representation of a Number is Palindrome Ninja is given an integer ‘N’. Ninja wants to find whether the binary representation of integer ‘N’ is palindrome or not. A palindrome is a sequence of c...

read more

Q78. Make Unique Array You are given an array ‘ARR’ of size ‘N,’ and you have to tell the minimum number of elements that need to be removed such that the array contains all distinct elements. More formally, there s...

read more

Q79. Distribute N candies among K people Sanyam has ‘N’ candies, he wants to distribute that into ‘K’ of his friends. He made his ‘K’ friends stand in line, in increasing order of his likeness. Not being so smart he...

read more

Q80. Median of two sorted arrays You are given two sorted arrays 'A' & 'B' of sizes 'N' & 'M'. You need to find the median of the two arrays when merged. If the total number of elements i.e., N + M is even then the ...

read more

Q81. Sort 0 1 You have been given an integer array/list(ARR) of size N that contains only integers, 0 and 1. Write a function to sort this array/list. Think of a solution which scans the array/list only once and don...

read more

Q82. Check Palindrome Ninja is given an integer ‘N’. Ninja wants to find whether the binary representation of integer ‘N’ is palindrome or not. A palindrome is a sequence of characters that reads the same backward a...

read more

Q83. Optimize The Code While practicing questions on data structures, Ninja faced a problem and was not able to pass all the test cases of a question as the time complexity of the code Ninja made was very large. Nin...

read more

Q84. Spiral Order Traversal of a Binary Tree 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...

read more

Q85. Number of Pairs with Given Sum You have been given an integer array/list(arr) and a number 'Sum'. Find and return the total number of pairs in the array/list which when added, results equal to the 'Sum'. Note: ...

read more

Q86. Check whether second string can be formed from characters of first string You are given two strings STR1 and STR2. You need to check whether STR2 can be formed from the characters of STR1. Both the strings can ...

read more

Q87. Jumping Game You are given ‘n’ carrots numbered from 1 to ‘n’. There are k rabbits. Rabbits can jump to carrots only with the multiples of Aj(Aj,2Aj,3Aj…) for all rabbits from 1 to k. Whenever Rabbit reaches a ...

read more

Q88. Reverse Stack Using Recursion Reverse a given stack of integers using recursion. Note: You are not allowed to use any extra space other than the internal stack space used due to recursion. You are not allowed t...

read more

Q89. String Transformation Given a string (STR) of length N, you have to create a new string by performing the following operation: Take the smallest character from the first 'K' characters of STR, remove it from ST...

read more

Q90. Segregate Odd-Even There is a wedding ceremony at NinjaLand. The bride and groom want everybody to play a game and thus, they have blindfolded the attendees. The people from the bride’s side are holding odd num...

read more

Q91. Smallest Window You are given two strings S and X containing random characters. Your task is to find the smallest substring in S which contains all the characters present in X. Example: Let S = “abdd” and X = “...

read more

Q92. 1. How to make object thread-safe? 2. Create an Immutable class. 3. Which Garbage collection algorithm is used in Java. 4. print the left view of the Binary tree 5. working of Circuiter breaker design pattern. ...

read more
Ans.
Technical interview questions for Associate Staff Engineer position To make an object thread-safe, use synchronization or use thread-safe data structures Immutable class is a class whose state cannot be modified after creation Java uses a mark-and-sweep algorithm for garbage collection To print the left view of a binary tree, perform a level order traversal and print the first node at each level Circuit breaker design pattern is used to prevent cascading failures in distribu...
read more

Q93. Count derangements Given a number ‘N', the task is to find the total number of derangements of a set of ‘N’ elements. A ‘Derangement’ is a permutation of 'N' elements, such that no element appears in its origin...

read more

Q94. Write a program: single input as a string(lets say "aaabcccfffghh"), you have to return the char and their occurrence as a string. In this case you have to return "a3b1c3f3g1h2"

Ans.
Program to return character and their occurrence in a string. Iterate through the string and count the occurrence of each character. Store the count in a dictionary or hashmap. Create a new string by concatenating the character and their count. Return the new string.

Q95. Factorial of a Number Write a program to find the factorial of a number. Factorial of n is: n! = n * (n-1) * (n-2) * (n-3)....* 1 Output the factorial of 'n'. If it does not exist, output 'Error'. Input format ...

read more

Q96. how would you handle overflow condition of an array? SB37,SD37,SE37,S0C4,S0C7?JCL - how to backup all GDG versions in one step? what are COMP & COMP-3 vars and what it's used for?

Ans.
Handling overflow condition of an array and backing up GDG versions in one step in JCL For overflow, check array bounds before accessing elements For SB37, increase primary/secondary space allocation For SD37, increase directory blocks For SE37, increase primary/secondary space allocation for PDS For S0C4, check for null pointers or uninitialized variables For S0C7, check for invalid data types or out-of-bounds array access To backup all GDG versions in one step, use the GDG...
read more

Q97. DFS Traversal Given an undirected and disconnected graph G(V, E), containing 'V' vertices and 'E' edges, the information about edges is given using 'GRAPH' matrix, where i-th edge is between GRAPH[i][0] and GRA...

read more

Q98. How to write HTML code considering web accessibility for disabled person

Ans.
Writing accessible HTML code for disabled persons Use semantic HTML tags to provide structure and meaning to the content Include alternative text for images and other non-text content Ensure color contrast meets accessibility standards Provide keyboard navigation and focus styles for interactive elements Use ARIA attributes to enhance accessibility for dynamic content Test with screen readers and other assistive technologies Consider using accessible frameworks and libraries...
read more

Q99. Aptitude Question

Find the angle between the minute and The hour clock
if its 4:10

Q100. Properties of MST in a Undirected Graph G = (V,E) is an undirected simple graph in which each edge has a distinct weight, and e is a particular edge of G. Which of the following statements about the minimum spa...

read more
1
2
3
4
5

More about working at Nagarro

#2 Best Large Company - 2022
#1 Best IT/ITES Company - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at null

based on 292 interviews in the last 1 year
Interview experience
3.9
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

4.0
241 Interview Questions
4.0
198 Interview Questions
4.0
190 Interview Questions
3.8
181 Interview Questions
3.6
164 Interview Questions
View all
Top Nagarro Interview Questions And Answers
Share Interview Advice
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 Lakh+

Reviews

4 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2023 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter