Add office photos
DE Shaw logo
Employer?
Claim Account for FREE

DE Shaw

3.8
based on 154 Reviews
Video summary
Filter interviews by
Software Developer
Fresher
Skills
Clear (1)

70+ DE Shaw Software Developer Interview Questions and Answers

Updated 23 Jun 2024

Q1. Tower Building Problem Statement

Given an array 'ARR' of 'N' cubes, you need to construct towers such that each cube can either be placed on top of an existing tower or start a new one. The restriction is that ...read more

Ans.

The task is to determine the minimum number of towers needed to stack cubes in a specific order.

  • Iterate through the array of cubes and maintain a stack to keep track of towers.

  • For each cube, check if it can be placed on an existing tower or start a new one.

  • Update the stack based on the cube's size and count the number of towers needed.

  • Return the minimum number of towers required.

  • Example: For input N = 3, ARR = [3, 2, 1], the output should be 1.

View 1 answer
right arrow

Q2. Rabbit Jumping Problem

Consider 'n' carrots numbered from 1 to 'n' and 'k' rabbits. Each rabbit jumps to carrots only at multiples of its respective jumping factor Aj (i.e., Aj, 2Aj, 3Aj, ...), for all rabbits ...read more

Ans.

Calculate uneaten carrots by rabbits with specific jumping factors.

  • Iterate through each carrot and check if any rabbit jumps on it.

  • Use the jumping factors to determine which carrots will be eaten.

  • Subtract the eaten carrots from the total to get the uneaten carrots.

Add your answer
right arrow
DE Shaw Software Developer Interview Questions and Answers for Freshers
illustration image

Q3. Coin Game Problem Statement

Wong wants to borrow money from Dr. Strange, who insists Wong must win a coin game first. The game involves two players taking turns to remove one coin from either end of a row of co...read more

Ans.

Given an array of coin values, determine the maximum value Wong can obtain by playing a coin game against Dr. Strange.

  • Wong plays first and can remove one coin from either end of the array on each turn.

  • The game ends when no coins are left, and the player with the highest total value wins.

  • Consider different scenarios like having an odd or even number of coins in the array.

Add your answer
right arrow

Q4. Maximum Number from Linked List Problem Statement

Given a linked list where each node contains a single digit, your task is to construct the largest possible number using these digits.

Objective:

Print the maxi...read more

Ans.

To find the maximum number that can be formed using the digits present in a linked list.

  • Traverse the linked list and store the digits in an array

  • Sort the array in descending order

  • Concatenate the sorted array elements to form the maximum number

Add your answer
right arrow
Discover DE Shaw interview dos and don'ts from real experiences

Q5. Money Saving in Bank Problem

Harshit wants to save up money for his first car by depositing money daily in the Ninja bank with a specific increment strategy.

Starting with 1 rupee on the first Monday, the amoun...read more

Ans.

Calculate the total money accumulated by Harshit in Ninja bank after N days with a specific increment strategy.

  • Start with 1 rupee on the first Monday and increase by 1 rupee each day from Tuesday to Sunday.

  • Each new Monday starts with an additional rupee more than the previous Monday's deposit.

  • Calculate the total amount of money accumulated after N days for each test case.

  • Example: For N = 2, total amount is 3 rupees; for N = 5, total amount is 15 rupees.

Add your answer
right arrow

Q6. K Most Frequent Elements Problem Statement

Given an integer array ARR and an integer K, identify the K most frequent elements within ARR. Return these elements sorted in ascending order.

Example:

Input:
ARR = [...read more
Ans.

Identify K most frequent elements in an array and return them sorted in ascending order.

  • Use a hashmap to store the frequency of each element in the array.

  • Sort the elements based on their frequency in descending order.

  • Return the first K elements from the sorted list.

Add your answer
right arrow
Are these interview questions helpful?

Q7. Stock Investment Problem Statement

You are given the prices of a particular stock over 'N' consecutive days. Your task is to find the maximum profit that can be obtained by completing at most two transactions. ...read more

Ans.

Find the maximum profit that can be obtained by completing at most two transactions of buying and selling a stock.

  • Iterate through the array of stock prices and calculate the maximum profit that can be obtained by completing at most two transactions.

  • Keep track of the maximum profit that can be obtained by selling the stock on each day after buying it on a previous day.

  • Consider all possible combinations of two transactions to find the maximum profit.

  • Return the maximum profit fo...read more

Add your answer
right arrow

Q8. Minimum Removals Problem Statement

Given an array ARR of size N and an integer K, determine the minimum number of elements that must be removed from the array so that the difference between the maximum and mini...read more

Ans.

The problem involves finding the minimum number of elements to remove from an array so that the difference between the maximum and minimum element is less than or equal to a given value.

  • Iterate through the array and keep track of the minimum and maximum elements.

  • Calculate the difference between the maximum and minimum elements.

  • If the difference is greater than the given value, increment the count of elements to remove.

  • Return the count of elements to remove as the result.

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Jump Game Problem Statement

You are given a list of points, and currently at point 0, your task is to determine if you can reach the last point N. At each point i, you can jump at most JUMP[i] length forward. C...read more

Ans.

The task is to determine if it is possible to reach the last point in a list of points by jumping a certain distance at each point.

  • Iterate through the list of points and check if it is possible to reach the last point by jumping the maximum distance at each point.

  • Keep track of the farthest point that can be reached from the current point.

  • If the farthest point that can be reached is greater than or equal to the last point, return True; otherwise, return False.

Add your answer
right arrow

Q10. LCS of Three Strings Problem Statement

Given three strings A, B, and C, determine the length of the longest common subsequence present in all three strings.

Explanation:

A subsequence is derived by deleting som...read more

Ans.

Find the length of the longest common subsequence among three strings.

  • Use dynamic programming to solve this problem efficiently.

  • Create a 3D array to store the lengths of common subsequences.

  • Iterate through the strings to fill the array and find the longest common subsequence length.

Add your answer
right arrow

Q11. Minimum Steps for a Knight to Reach Target

Given a square chessboard of size 'N x N', determine the minimum number of moves a Knight requires to reach a specified target position from its initial position.

Expl...read more

Ans.

Calculate the minimum number of moves a Knight requires to reach a specified target position on a chessboard.

  • Implement a function that calculates the minimum number of moves for a Knight to reach the target position on an NxN chessboard.

  • Consider the possible movements of a Knight on a chessboard (2 squares in one direction and 1 square in a perpendicular direction).

  • Use breadth-first search (BFS) algorithm to find the shortest path from the Knight's starting position to the ta...read more

Add your answer
right arrow
Q12. ...read more

Evaluate Reverse Polish Notation Problem Statement

You are provided with an arithmetic expression in Reverse Polish Notation represented as an array EXP. Your task is to calculate the value of this expression.

Ans.

Evaluate arithmetic expression in Reverse Polish Notation using stack.

  • Use a stack to keep track of operands and perform operations when encountering an operator.

  • Iterate through the array of strings and push operands onto the stack, perform operation when an operator is encountered.

  • Handle division using modular division to avoid floating point precision issues.

  • Return the final result modulo 10^9 + 7 as specified in the constraints.

Add your answer
right arrow

Q13. Chocolate Distribution Problem

You are given an array/list CHOCOLATES of size 'N', where each element represents the number of chocolates in a packet. Your task is to distribute these chocolates among 'M' stude...read more

Ans.

Distribute chocolates among students to minimize difference between largest and smallest packets.

  • Sort the array of chocolates packets.

  • Use sliding window technique to find the minimum difference between largest and smallest packets distributed to students.

  • Return the minimum difference as the output.

Add your answer
right arrow

Q14. Count Smaller People on Right

You are provided with an array called HEIGHT that contains the heights of 'N' people standing in a queue. For each person in the array, compute the number of individuals on their r...read more

Ans.

Count the number of people to the right with a smaller height for each person in a queue.

  • Iterate through the array from right to left and maintain a sorted list of heights encountered so far.

  • Use binary search to find the position where the current height should be inserted in the sorted list.

  • The count of smaller people to the right for each person can be calculated based on the index of insertion in the sorted list.

Add your answer
right arrow

Q15. Gas Station Tour Problem

You are presented with a circular track consisting of several petrol pumps. Each petrol pump is indexed from 0 to N-1 and offers certain attributes:

  • The quantity of petrol available at...read more
Ans.

Find the first petrol pump from which a truck can start its journey and complete the circle.

  • Iterate through each petrol pump and calculate the remaining petrol after reaching the next pump.

  • If the remaining petrol is negative at any point, reset the starting point to the next pump.

  • If the total remaining petrol at the end is non-negative, return the starting point as the answer.

Add your answer
right arrow

Q16. Conquering the Best Kingdom Problem Statement

Aragorn, an influential ruler, aspires to expand his power by conquering more kingdoms. There are 'N' kingdoms numbered from 0 to N-1, forming a tree structure. The...read more

Ans.

Given a tree structure of kingdoms, determine if it's possible to conquer more kingdoms than Aragorn by strategically choosing the starting kingdom.

  • Start at the kingdom adjacent to Aragorn's initial kingdom

  • Choose the kingdom that allows you to capture the most number of kingdoms in subsequent turns

  • Consider the tree structure to plan your conquest strategically

Add your answer
right arrow

Q17. Problem Statement: Sibling Nodes

You are provided with a Binary Tree consisting of 'N' nodes, where each node holds an integer value. Your objective is to identify and list all nodes that do not possess a sibli...read more

Ans.

Identify and list nodes in a Binary Tree without siblings.

  • Traverse the Binary Tree in level order and keep track of nodes without siblings.

  • Check if each node has a sibling by comparing with its parent's other child.

  • Output the values of nodes without siblings in ascending order.

Add your answer
right arrow

Q18. Bottom View of Binary Tree

Given a binary tree, determine and return its bottom view when viewed from left to right. Assume that each child of a node is positioned at a 45-degree angle from its parent.

Nodes in...read more

Ans.

Return the bottom view of a binary tree when viewed from left to right.

  • Traverse the tree in level order and keep track of horizontal distance and depth of each node

  • For each horizontal distance, update the node in the map if it is deeper than the current node

  • Return the values of the map in sorted order of horizontal distance

Add your answer
right arrow

Q19. Minimum Number of Taps to Water the Garden

Given a garden that extends along a one-dimensional x-axis from point 0 to point N, your task is to determine the minimum number of taps needed to water the entire gar...read more

Ans.

Find the minimum number of taps needed to water the entire garden using given tap ranges.

  • Iterate over taps and update the farthest point each tap can reach.

  • Use a greedy approach to select the tap that can water the farthest point.

  • If a tap can't water any point, return -1.

  • Example: For ranges = [3, 4, 1, 1, 0, 0], tap at position 1 can water the entire garden.

Add your answer
right arrow

Q20. Buy and Sell Stock Problem Statement

Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell transa...read more

Ans.

The task is to determine the maximum profit that can be achieved by performing up to two buy-and-sell transactions on a given set of stock prices.

  • Iterate through the array of stock prices and calculate the maximum profit that can be achieved by buying and selling at different points.

  • Keep track of the maximum profit after the first transaction and the maximum profit after the second transaction.

  • Return the sum of these two maximum profits as the final result.

  • Example: For input ...read more

Add your answer
right arrow

Q21. Dijkstra's Algorithm for Shortest Path

Given an undirected graph with 'V' vertices labeled from 0 to V-1 and 'E' edges. Each edge has a weight that represents the distance between two nodes 'X' and 'Y'.

Your ta...read more

Ans.

Dijkstra's algorithm is used to find the shortest path distances from a source node to all other vertices in a graph.

  • Dijkstra's algorithm is a greedy algorithm that finds the shortest path from a source node to all other nodes in a graph.

  • It uses a priority queue to select the node with the smallest distance and relaxes its neighbors.

  • The algorithm maintains a distance array to keep track of the shortest distances from the source node.

  • If a node is unreachable, the distance is s...read more

Add your answer
right arrow

Q22. LCA in a Binary Search Tree

You are given a binary search tree (BST) containing N nodes. Additionally, you have references to two nodes, P and Q, within this BST.

Your task is to determine the Lowest Common Anc...read more

Ans.

Find the Lowest Common Ancestor (LCA) of two nodes in a Binary Search Tree (BST).

  • Traverse the BST from the root node to find the LCA of nodes P and Q.

  • Compare the values of nodes P and Q with the current node's value to determine the LCA.

  • If both nodes are on the same side of the current node, move to that side; otherwise, the current node is the LCA.

  • Handle cases where one node is the ancestor of the other node.

  • Example: For input 2 3 and BST 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -...read more

Add your answer
right arrow

Q23. Phone Directory Search Directory

You are given a list/array of strings representing the contacts in a phone directory. The task is to perform a search based on a query string 'str' and return all contacts that ...read more

Ans.

Implement a phone directory search feature to suggest contacts based on a given prefix query string.

  • Iterate through the contact list to find contacts with the prefix matching the query string.

  • Display suggestions as the user types each character of the query.

  • Handle cases where no suggestions are found for a particular prefix by printing 'No suggestions found'.

Add your answer
right arrow

Q24. Find Triplets with Given Sum Problem Statement

Given an array ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a given integer K.

Explanation:

An arra...read more

Ans.

The task is to find all distinct triplets in an array that sum up to a given integer.

  • Iterate through the array and use nested loops to find all possible triplets.

  • Use a set to store unique triplets and avoid duplicates.

  • Check if the sum of the triplet equals the target sum.

  • Return the list of valid triplets or -1 if no such triplet exists.

Add your answer
right arrow

Q25. Find Magic Index in Sorted Array

Given a sorted array A consisting of N integers, your task is to find the magic index in the given array, where the magic index is defined as an index i such that A[i] = i.

Exam...read more

Ans.

Find the magic index in a sorted array where A[i] = i.

  • Use binary search to efficiently find the magic index in the sorted array.

  • Check the middle element of the array and compare it with its index to determine the direction to search.

  • Repeat the process on the left or right half of the array until the magic index is found or no more elements to search.

Add your answer
right arrow

Q26. Longest Increasing Path in a 2D Matrix Problem Statement

Given a matrix of non-negative integers of size 'N x M', where 'N' and 'M' denote the number of rows and columns respectively, find the length of the lon...read more

Ans.

Find the length of the longest increasing path in a 2D matrix by moving in four directions.

  • Use dynamic programming to keep track of the longest increasing path starting from each cell.

  • Explore all four directions from each cell and recursively find the longest increasing path.

  • Optimize the solution by storing the length of the longest increasing path starting from each cell.

Add your answer
right arrow

Q27. Binary Tree Mirror Conversion Problem

Given a binary tree, your task is to convert it into its mirror tree.

A binary tree is a data structure where each parent node has at most two children.

The mirror of a bin...read more

Ans.

Convert a binary tree into its mirror tree by interchanging left and right children of non-leaf nodes.

  • Traverse the binary tree in postorder fashion and swap the left and right children of each non-leaf node.

  • Use recursion to solve the problem efficiently.

  • Remember to handle null child nodes represented by -1 in the input.

Add your answer
right arrow

Q28. Maximum Sum Subarray Problem Statement

Given an array of integers, find the maximum sum of any contiguous subarray within the array.

Example:

Input:
array = [34, -50, 42, 14, -5, 86]
Output:
137
Explanation:

Th...read more

Ans.

Find the maximum sum of any contiguous subarray within an array in O(N) time complexity.

  • Iterate through the array and keep track of the maximum sum of subarrays encountered so far

  • At each index, decide whether to include the current element in the subarray or start a new subarray

  • Update the maximum sum if a new maximum is found

  • Example: For array [34, -50, 42, 14, -5, 86], the maximum sum subarray is [42, 14, -5, 86] with sum 137

Add your answer
right arrow

Q29. Minimum Number of Platforms Problem

Your task is to determine the minimum number of platforms required at a railway station so that no train has to wait.

Explanation:

Given two arrays:

  • AT - representing the ar...read more
Ans.

Determine the minimum number of platforms needed at a railway station so that no train has to wait.

  • Sort the arrival and departure times arrays in ascending order.

  • Initialize two pointers for arrival and departure times, and a variable to keep track of the maximum number of platforms needed.

  • Increment the platform count when a train arrives and decrement when a train departs.

  • Update the maximum platform count as needed.

  • Return the maximum platform count as the minimum number of pl...read more

Add your answer
right arrow

Q30. Find the Largest BST Subtree in a Given Binary Tree

Your task is to determine the size of the largest subtree of a given binary tree which is also a Binary Search Tree (BST).

BST Definition:

  • The left subtree o...read more
Ans.

Find the size of the largest subtree in a binary tree that is also a Binary Search Tree (BST).

  • Traverse the binary tree in a bottom-up manner to check if each subtree is a BST.

  • Keep track of the size of the largest BST subtree encountered so far.

  • Use the properties of a BST to determine if a subtree is a valid BST.

  • Consider edge cases such as empty tree or single node tree.

  • Example: For input 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1, the output should be 3.

Add your answer
right arrow

Q31. Two cops and a robber are located on opposite corners of a cube and move along its edges. They all move at the same rate. Is it possible for the cops to catch the robber. [Each of the 3 people can see each othe...

read more
Ans.

No, it is not possible for the cops to catch the robber.

  • The robber can always stay equidistant from the cops by moving along the diagonal of the cube.

  • The cops can never cut off the robber's path without colliding with each other.

  • This problem is known as the '3 Cops and a Robber' problem in graph theory.

Add your answer
right arrow

Q32. Next Higher and Previous Lower Number with Same Number of Set Bits

Given a positive integer n, the task is to find the next smallest integer and the previous largest integer that contain the exact same number o...read more

Ans.

Find next smallest and previous largest integers with same number of set bits as given integer.

  • Count the number of set bits in the given integer using bitwise operations.

  • For next smallest integer, find the next number with same number of set bits by iterating through numbers greater than the given integer.

  • For previous largest integer, find the previous number with same number of set bits by iterating through numbers smaller than the given integer.

Add your answer
right arrow

Q33. In some tournament 139 teams have participated. Tournament is knock out. what is the number of matches to choose the champion to be held?

Ans.

139 teams in a knock-out tournament, find the number of matches to choose the champion.

  • In a knock-out tournament, each team plays only one match per round.

  • The number of matches required to choose the champion is one less than the number of teams.

  • Therefore, the number of matches required is 138.

Add your answer
right arrow
Q34. What is the Diamond Problem in C++ and how can it be resolved?
Ans.

Diamond Problem is a common issue in multiple inheritance in C++ where a class inherits from two classes that have a common base class.

  • Diamond Problem occurs when a class inherits from two classes that have a common base class, leading to ambiguity in accessing members.

  • It can be resolved in C++ using virtual inheritance, where the common base class is inherited virtually to avoid duplicate copies of base class members.

  • Example: class A is inherited by classes B and C, and clas...read more

Add your answer
right arrow
Q35. What is meant by garbage collection in the context of Object-Oriented Programming (OOP)?
Ans.

Garbage collection in OOP refers to automatic memory management by deallocating memory of objects no longer in use.

  • Garbage collection is a process of automatically reclaiming memory occupied by objects that are no longer in use.

  • It helps prevent memory leaks and ensures efficient memory usage.

  • Languages like Java, C#, and Python have built-in garbage collection mechanisms.

  • Garbage collection can be done using different algorithms like mark and sweep, reference counting, and gene...read more

Add your answer
right arrow
Q36. What is the difference between internal fragmentation and external fragmentation in operating systems?
Ans.

Internal fragmentation occurs when memory is allocated in fixed-size blocks, leading to wasted space within a block. External fragmentation occurs when free memory is fragmented into small chunks, making it difficult to allocate contiguous blocks.

  • Internal fragmentation is caused by allocating fixed-size blocks of memory, leading to wasted space within a block.

  • External fragmentation occurs when free memory is fragmented into small chunks, making it difficult to allocate contig...read more

Add your answer
right arrow

Q37. What is the difference between default and copy constructor?

Ans.

Default constructor is provided by the compiler if no constructor is defined. Copy constructor creates a new object by copying an existing object.

  • Default constructor initializes member variables to default values.

  • Copy constructor creates a new object with the same values as an existing object.

  • Default constructor is called automatically by the compiler if no constructor is defined.

  • Copy constructor is called when an object is passed by value or when a new object is initialized ...read more

Add your answer
right arrow

Q38. What is the difference between primary key and unique key?

Ans.

Primary key uniquely identifies a record in a table, while unique key ensures that all values in a column are distinct.

  • Primary key can't have null values, while unique key can have one null value.

  • A table can have only one primary key, but multiple unique keys.

  • Primary key is used as a foreign key in other tables, while unique key is not.

  • Example: Primary key - employee ID, Unique key - email address.

Add your answer
right arrow

Q39. What is the difference between Truncate and Delete?

Ans.

Truncate removes all data from a table while Delete removes specific data from a table.

  • Truncate is faster than Delete as it doesn't log individual row deletions.

  • Truncate resets the identity of the table while Delete doesn't.

  • Truncate can't be rolled back while Delete can be.

  • Truncate doesn't fire triggers while Delete does.

Add your answer
right arrow
Q40. Can you define processes and threads in operating systems?
Ans.

Processes are instances of programs in execution, while threads are smaller units within a process that can execute independently.

  • Processes are independent entities that contain program code, data, and resources.

  • Threads are lightweight units within a process that share the same resources but can execute independently.

  • Processes have their own memory space, while threads share the same memory space.

  • Processes communicate with each other through inter-process communication mechan...read more

Add your answer
right arrow
Q41. What is the difference between a Default Constructor and a Copy Constructor in Object-Oriented Programming?
Ans.

Default Constructor is a constructor that is automatically called when an object is created without any arguments. Copy Constructor is used to create a new object as a copy of an existing object.

  • Default Constructor has no parameters, while Copy Constructor takes an object of the same class as a parameter.

  • Default Constructor initializes the object with default values, while Copy Constructor creates a new object with the same values as the existing object.

  • Example: Default Const...read more

Add your answer
right arrow

Q42. Write an algorithm to find the absolute max subsequence of an array containing both positive and negative numbers in O(n) time ?

Ans.

Algorithm to find absolute max subsequence of an array with positive and negative numbers in O(n) time.

  • Initialize max_so_far and max_ending_here as 0

  • Loop through the array and for each element, add it to max_ending_here

  • If max_ending_here becomes negative, reset it to 0

  • If max_ending_here is greater than max_so_far, update max_so_far

  • Return max_so_far

Add your answer
right arrow
Q43. What is the difference between an abstract class and an interface in Java?
Ans.

Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.

  • Abstract class can have constructor, member variables, and methods with implementation.

  • Interface can only have abstract methods and constants.

  • A class can implement multiple interfaces but can only extend one abstract class.

  • Example: Abstract class - Animal with abstract method 'eat' and non-abstract method 'sleep'. Interface - Flyable with method 'fly'.

Add your answer
right arrow
Q44. What are the key differences between a Primary Key and a Unique Key in a database management system?
Ans.

Primary Key uniquely identifies each record in a table, while Unique Key ensures that all values in a column are distinct.

  • Primary Key does not allow NULL values, while Unique Key allows one NULL value.

  • A table can have only one Primary Key, but multiple Unique Keys.

  • Primary Key is automatically indexed, while Unique Key may or may not be indexed.

  • Primary Key is used to establish relationships between tables, while Unique Key is used to enforce data integrity.

  • Example: In a table ...read more

Add your answer
right arrow

Q45. What is the difference between C and C++?

Ans.

C++ is an extension of C with object-oriented programming features.

  • C++ supports classes and objects while C does not.

  • C++ has better support for polymorphism and inheritance.

  • C++ has a standard template library (STL) which C does not have.

  • C++ allows function overloading while C does not.

  • C++ has exception handling while C does not.

Add your answer
right arrow
Q46. What are the advantages of system calls in operating systems?
Ans.

System calls provide a way for user-level processes to interact with the operating system kernel.

  • System calls allow user programs to request services from the operating system.

  • They provide a secure and controlled way for applications to access system resources.

  • System calls enable processes to perform tasks such as file operations, network communication, and process management.

  • Examples of system calls include open(), read(), write(), fork(), and exec().

Add your answer
right arrow
Q47. What is the difference between DDL (Data Definition Language) and DML (Data Manipulation Language)?
Ans.

DDL is used to define the structure of database objects, while DML is used to manipulate data within those objects.

  • DDL is used to create, modify, and delete database objects like tables, indexes, etc.

  • DML is used to insert, update, delete, and retrieve data from database tables.

  • DDL statements include CREATE, ALTER, DROP, TRUNCATE, etc.

  • DML statements include INSERT, UPDATE, DELETE, SELECT, etc.

Add your answer
right arrow

Q48. Find the next largest int of a given int such that it has same number of 1′s in binary?

Ans.

Find the next largest int with same number of 1's in binary.

  • Count the number of 1's in the binary representation of the given int.

  • Increment the given int until a number with the same number of 1's is found.

  • Return the next largest int with same number of 1's.

Add your answer
right arrow

Q49. What is the difference between DML and DLL?

Ans.

DML is Data Manipulation Language used to manipulate data in a database. DLL is Data Definition Language used to define database schema.

  • DML is used to insert, update, delete data in a database.

  • DLL is used to create, alter, drop database objects like tables, views, indexes.

  • DML statements include INSERT, UPDATE, DELETE.

  • DLL statements include CREATE, ALTER, DROP.

  • DML affects data in a database, DLL affects the structure of a database.

Add your answer
right arrow

Q50. What is the difference between DBMS and RDBMs?

Ans.

DBMS is a software system to manage databases while RDBMS is a type of DBMS that uses a relational model.

  • DBMS stands for Database Management System while RDBMS stands for Relational Database Management System.

  • DBMS can manage any type of database while RDBMS uses a relational model to manage data.

  • DBMS does not enforce any specific data model while RDBMS enforces a relational data model.

  • Examples of DBMS include MongoDB, Cassandra, and Redis while examples of RDBMS include MySQL...read more

Add your answer
right arrow

Q51. task schedular from leetcode second is : N piles of coins diffrent length you can add or remove one coin from a pile adding cost c1 and removing cost c2 find minimum cost such that height of n piles equals

Ans.

Find minimum cost to make heights of N piles of coins equal by adding or removing one coin from a pile with different costs.

  • Use dynamic programming to keep track of the minimum cost for each pile height.

  • Consider the cost of adding and removing coins from each pile.

  • Iterate through all possible combinations of adding and removing coins to find the minimum cost.

Add your answer
right arrow
Q52. What are the different types of semaphores?
Ans.

Different types of semaphores include binary semaphores, counting semaphores, and mutex semaphores.

  • Binary semaphores: Can only have two states - 0 or 1. Used for mutual exclusion.

  • Counting semaphores: Can have multiple states. Used for resource allocation and synchronization.

  • Mutex semaphores: Similar to binary semaphores but with additional features like priority inheritance and deletion safety.

Add your answer
right arrow

Q53. Given an array eliminate the duplicates and print it. Linear time complexity?

Ans.

Eliminate duplicates in an array of strings and print it in linear time complexity.

  • Use a hash set to keep track of unique elements

  • Iterate through the array and add non-duplicate elements to the hash set

  • Print the hash set elements to get the final array

Add your answer
right arrow
Q54. What is inheritance in object-oriented programming?
Ans.

Inheritance is a concept in object-oriented programming where a class inherits properties and behaviors from another class.

  • Allows for code reusability by creating a new class based on an existing class

  • Child class inherits attributes and methods of the parent class

  • Can have multiple levels of inheritance (e.g. grandparent, parent, child classes)

  • Example: class Dog extends Animal, where Dog inherits properties and methods from Animal class

Add your answer
right arrow
Q55. What are the objectives of normalization in database management systems?
Ans.

Normalization in database management systems aims to reduce data redundancy, improve data integrity, and optimize database performance.

  • Eliminate data redundancy by breaking down data into smaller tables

  • Reduce update anomalies by ensuring data is stored in a logical and consistent manner

  • Improve data integrity by enforcing referential integrity constraints

  • Optimize database performance by reducing the amount of redundant data stored

Add your answer
right arrow
Q56. Can you explain the select() system call?
Ans.

The select() system call is used in Unix-like operating systems to monitor multiple file descriptors for activity.

  • select() allows a program to wait for multiple I/O operations to complete on multiple file descriptors.

  • It takes three sets of file descriptors as arguments - readfds, writefds, and errorfds.

  • The function will block until an activity is detected on one of the file descriptors or until a timeout occurs.

  • select() is commonly used in networking applications to handle mu...read more

Add your answer
right arrow

Q57. What is the purpose of Normalisation?

Ans.

Normalisation is the process of organizing data in a database to reduce redundancy and improve data integrity.

  • Normalisation helps to eliminate data redundancy and inconsistencies

  • It ensures that each piece of data is stored in only one place

  • It helps to improve data integrity and accuracy

  • It makes it easier to maintain and update the database

  • There are different levels of normalisation, each with its own set of rules and guidelines

Add your answer
right arrow
Q58. Write an SQL query to find the employee with the nth highest salary.
Ans.

SQL query to find the employee with the nth highest salary

  • Use the ORDER BY clause to sort salaries in descending order

  • Use the LIMIT clause to select the nth highest salary

  • Join the employee table with the salary table to get the employee details

Add your answer
right arrow
Q59. What are the types of access modifiers in C++?
Ans.

The types of access modifiers in C++ are public, private, and protected.

  • Public: accessible from outside the class

  • Private: only accessible within the class

  • Protected: accessible within the class and its subclasses

Add your answer
right arrow

Q60. What are class access modifiers?

Ans.

Class access modifiers are keywords used to control the visibility and accessibility of class members.

  • There are four access modifiers in Java: public, private, protected, and default

  • Public members can be accessed from anywhere

  • Private members can only be accessed within the same class

  • Protected members can be accessed within the same class, subclasses, and same package

  • Default members can be accessed within the same package

Add your answer
right arrow

Q61. find maximum length BST in a given binary tree?

Ans.

To find the maximum length BST in a given binary tree.

  • Traverse the tree in post-order fashion

  • For each node, check if it satisfies the BST property

  • If it does, calculate the size of the BST rooted at that node

  • Keep track of the maximum size seen so far

Add your answer
right arrow

Q62. Write algo to mirror a given Binary Tree?

Ans.

Algorithm to mirror a given Binary Tree

  • Create a function to swap left and right child nodes of a given node

  • Recursively call the function on left and right child nodes

  • Base case: if node is null, return

  • Call the function on the root node of the binary tree

Add your answer
right arrow

Q63. What are access specifiers?

Ans.

Access specifiers are keywords in object-oriented programming languages that determine the visibility and accessibility of class members.

  • Access specifiers are used to restrict access to class members.

  • There are three types of access specifiers: public, private, and protected.

  • Public members can be accessed from anywhere in the program.

  • Private members can only be accessed within the class.

  • Protected members can be accessed within the class and its subclasses.

  • Example: class MyClas...read more

Add your answer
right arrow

Q64. What is library functions?

Ans.

Library functions are pre-written code that can be reused to perform common tasks.

  • Library functions save time and effort by providing pre-written code.

  • They are often included in programming languages or external libraries.

  • Examples include functions for string manipulation, mathematical calculations, and file input/output.

  • Library functions can be called from within a program to perform specific tasks.

  • They can also be customized or extended to fit specific needs.

Add your answer
right arrow

Q65. What is Recursion Function?

Ans.

Recursion function is a function that calls itself until a base condition is met.

  • Recursion is a technique used to solve problems by breaking them down into smaller sub-problems.

  • It involves a function calling itself with a modified input until a base case is reached.

  • Recursion can be used to solve problems such as factorial, Fibonacci series, and binary search.

  • Recursion can be implemented using loops as well, but it may not always be efficient.

  • Recursion can lead to stack overfl...read more

Add your answer
right arrow

Q66. What is serialization?

Ans.

Serialization is the process of converting an object into a format that can be stored or transmitted.

  • Serialization is used to save the state of an object and recreate it later.

  • It is commonly used in network communication to transmit data between different systems.

  • Examples of serialization formats include JSON, XML, and binary formats like Protocol Buffers.

  • Deserialization is the opposite process of converting serialized data back into an object.

Add your answer
right arrow
Q67. How is Java platform independent?
Ans.

Java is platform independent due to its bytecode and JVM.

  • Java code is compiled into bytecode, which can run on any platform with a Java Virtual Machine (JVM)

  • JVM acts as an intermediary between the Java code and the underlying platform, ensuring portability

  • Developers write code once and it can be executed on any platform that has a compatible JVM

  • Examples: Windows, macOS, Linux all can run Java programs without any changes

Add your answer
right arrow

Q68. Balancing of Btrees / AVL trees?

Ans.

Balancing of Btrees / AVL trees is important for efficient search and insertion operations.

  • Btrees and AVL trees are self-balancing binary search trees.

  • Balancing ensures that the height of the tree is minimized, leading to faster search and insertion operations.

  • Btrees are used in databases while AVL trees are used in memory.

  • Balancing is achieved by performing rotations and node splitting.

  • AVL trees have a stricter balancing condition than Btrees, leading to higher overhead but ...read more

Add your answer
right arrow

Q69. What is inheritance?

Ans.

Inheritance is a mechanism in object-oriented programming where a new class is created by inheriting properties of an existing class.

  • Inheritance allows code reusability and saves time and effort in programming.

  • The existing class is called the superclass or parent class, and the new class is called the subclass or child class.

  • The subclass inherits all the properties and methods of the superclass and can also add its own unique properties and methods.

  • For example, a class 'Anima...read more

Add your answer
right arrow

Q70. What is a stack?

Ans.

A stack is a data structure that follows the Last-In-First-Out (LIFO) principle.

  • Elements are added to the top of the stack and removed from the top.

  • Common operations include push (add element) and pop (remove element).

  • Stacks can be implemented using arrays or linked lists.

  • Examples include the call stack in programming and the undo/redo feature in text editors.

Add your answer
right arrow

Q71. What is an Assembly?

Ans.

Assembly is a low-level programming language that is used to write programs that can directly interact with computer hardware.

  • Assembly language is specific to a particular computer architecture.

  • It is a low-level language that is difficult to read and write.

  • Assembly language programs are faster and more efficient than programs written in high-level languages.

  • Examples of assembly language include x86, ARM, and MIPS.

  • Assembly language is often used for system-level programming, d...read more

Add your answer
right arrow
Q72. What is a Daemon Process?
Ans.

A daemon process is a background process that runs continuously to perform system tasks.

  • Daemon processes do not have a controlling terminal.

  • They typically run in the background and perform tasks such as managing hardware devices, network services, or system maintenance.

  • Examples of daemon processes include cron, sshd, and apache.

  • Daemon processes are often started during system boot and run until the system is shut down.

Add your answer
right arrow

Q73. OOP Java Design problems

Ans.

Answering OOP Java design problems

  • Identify the problem domain and create a class hierarchy

  • Use encapsulation to hide implementation details

  • Apply inheritance to reuse code and create subtypes

  • Implement polymorphism to allow objects to take on multiple forms

  • Avoid tight coupling and favor composition over inheritance

  • Use design patterns to solve common problems

  • Consider SOLID principles for maintainable code

Add your answer
right arrow
Q74. What is a virtual function?
Ans.

A virtual function is a function in a base class that is declared using the keyword 'virtual' and can be overridden by a function with the same signature in a derived class.

  • Virtual functions allow for dynamic polymorphism in object-oriented programming.

  • They are used to achieve runtime binding and enable the implementation of the function to be determined during runtime.

  • Example: virtual void display() = 0; in a base class and void display() override in a derived class.

Add your answer
right arrow

Q75. OOP concepts in Java

Ans.

OOP concepts in Java

  • Encapsulation - hiding implementation details

  • Inheritance - creating new classes from existing ones

  • Polymorphism - ability of objects to take on multiple forms

  • Abstraction - focusing on essential features and ignoring the rest

  • Example: A Car class can inherit from a Vehicle class

  • Example: A Dog class can have a bark() method that overrides the Animal class's makeSound() method

  • Example: A Shape class can have an abstract method called calculateArea()

  • Example: A Ba...read more

Add your answer
right arrow

Q76. Burn A Node in a Binary Tree

Ans.

To burn a node in a binary tree, we mark the node as burned and then recursively burn its left and right children.

  • Mark the current node as burned

  • Recursively burn the left child

  • Recursively burn the right child

Add your answer
right arrow
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at DE Shaw Software Developer

based on 4 interviews
2 Interview rounds
Coding Test Round
Video Call Round
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

Google Logo
4.4
 • 85 Interview Questions
Visa Logo
3.5
 • 18 Interview Questions
 UST Logo
3.8
 • 16 Interview Questions
View all
Recently Viewed
INTERVIEWS
Genpact
No Interviews
INTERVIEWS
Genpact
No Interviews
INTERVIEWS
EPAM Systems
10 top interview questions
INTERVIEWS
DXC Technology
No Interviews
INTERVIEWS
Infosys
No Interviews
REVIEWS
AU Small Finance Bank
No Reviews
REVIEWS
AU Small Finance Bank
No Reviews
INTERVIEWS
Altimetrik
10 top interview questions
INTERVIEWS
Accenture
No Interviews
INTERVIEWS
Capgemini
No Interviews
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

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