
Nagarro


Nagarro SDE Interview Questions and Answers
Q1. Partition to K Equal Sum Subsets Problem
Given an array of integers and a positive integer 'K', determine if it is possible to divide the array into 'K' non-empty subsets such that the sum of elements in each s...read more
The problem involves dividing an array into K subsets with equal sum.
Use backtracking to try all possible combinations of subsets.
Keep track of the sum of elements in each subset and check if they are equal to the target sum.
Optimize by sorting the array in descending order and assigning elements to subsets greedily.
Handle edge cases like when the sum of elements is not divisible by K.
Q2. Sort a "K" Sorted Doubly Linked List
Given a doubly-linked list with N
nodes, where each node’s position deviates at most K
positions from its position in the sorted list, your task is to sort this given doubly...read more
Sort a doubly linked list where each node's position deviates at most K positions from its position in the sorted list.
Iterate through the doubly linked list and maintain a min-heap of size K+1 to keep track of the next smallest element.
Remove the smallest element from the heap and add it to the sorted list. Update the heap with the next element from the removed node's next position.
Continue this process until all nodes are added to the sorted list.
Q3. Maximum Meetings Selection
You are tasked with scheduling meetings in a single meeting room. Given N
meetings, each with a start time Start[i]
and end time End[i]
, determine the maximum number of meetings that ...read more
Given start and end times of meetings, find the maximum number of meetings that can be scheduled in a single room.
Sort the meetings based on their end times in ascending order.
Iterate through the sorted meetings and select the ones that do not overlap with the previously selected meetings.
Keep track of the selected meetings and return their indices.
Q4. Merge k Sorted Linked Lists
You are provided with 'K' sorted linked lists, each sorted in increasing order. Your task is to merge all these lists into one single sorted linked list and return the head of the re...read more
Merge k sorted linked lists into one single sorted linked list.
Create a min-heap to store the heads of all linked lists.
Pop the smallest element from the heap and add it to the result list.
If the popped element has a next element, push it back to the heap.
Repeat until all elements are merged into a single sorted list.
Q5. Duplicate Subtrees Problem Statement
Given a binary tree, return the root values of all duplicate subtrees. Two subtrees are considered duplicate if they have the same structure with identical node values. For ...read more
Find root values of duplicate subtrees in a binary tree.
Traverse the tree in a bottom-up manner to identify duplicate subtrees.
Use a hashmap to store the subtree structures and their frequencies.
Return the root values of duplicate subtrees based on hashmap entries.
Keys in database management systems are unique identifiers for rows in a table.
Keys ensure data integrity by enforcing uniqueness and relationships between tables.
Primary key uniquely identifies each record in a table (e.g. employee ID).
Foreign key establishes a link between two tables by referencing the primary key of another table.
More about working at Nagarro







Interview Process at Nagarro SDE

Top SDE Interview Questions from Similar Companies





Reviews
Interviews
Salaries
Users/Month

