DE Shaw
100+ Interview Questions and Answers
You are given ‘N’ cubes in an array ‘ARR’ in a certain order, and your task is to build towers using them. Whenever two cubes are on top of the other, the upper cube must be smaller than the lower cube.
Y...read more
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
Wong is hungry and wants to eat tuna melt. He checks his pocket and finds that he has only a buck left. He asked Dr. Strange to lend him some money, for which Strange agrees but to get the money, Wong ...read more
You are given a string 'STR' representing JSON object. Return an array of strings denoting JSON objects with proper indentation.
Rules for proper indentation:
1. Every inner brace should increase one...read more
Given a linked list such that each node represents a digit. Construct the maximum number possible from the given digits.
You just need to print the maximum Integer that can be formed
Input fo...read more
You are Harshad Mehta’s friend. He told you the price of a particular stock for the next ‘N’ days. You can either buy or sell a stock. Also, you can only complete at most 2-transactions. Find th...read more
You are given an Integer array ‘ARR’ and an Integer ‘K’. Your task is to find the ‘K’ most frequent elements in ‘ARR’. Return the elements sorted in ascending order.
For Example:
You are...read more
Given two integers ‘Left’ and ‘Right’. Your task is to find the total count of ‘megaprime’ numbers from the range ‘Left’ to ‘Right’. A ‘megaprime’ number is a prime number and its individual di...read more
Harshit wants to save money for his first car. So, he puts money in the Ninja bank every day.
He starts by putting in ‘1’ rupee on Monday, the first day. Every day from Tuesday to Sunday, he will p...read more
A high-security meeting has been arranged. Tables for the delegates and security personnel have been arranged. A total of ‘N’ rows of tables has been set up. The first row has one table, the sec...read more
Given three strings A, B and C, the task is to find the length of the longest common sub-sequence in all the three strings A, B and C.
A subsequence of a string is a new string generated from th...read more
You’re given an array ‘ARR’ of size N and an integer K. Your task is to determine the minimum number of elements that should be removed from the array such that the difference between the maximu...read more
You have joined a fitness club and your fitness trainer has started your jumping routine.
There are N points and you are currently at point 0. Your goal is to reach point N. When you are at point i, yo...read more
The gardener wants to water the garden by opening the minimum number of taps. The garden is one-dimensional along the x-axis of length N i.e. the garden starts from point 0...read more
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 t...read more
You are given a sorted array A consisting of N integers. Your task is to find the magic index in the given array.
Note :
A magic index in an array A[0 ... N - 1] is defined to be an index i such that...read more
You are given two arrays/lists ‘A’ and ‘B’ of size ‘N’ each. You are also given an integer ‘K’. You have to find the ‘K’ maximum and valid sum combinations from all the possible sum combin...read more
You are given a 2D matrix ‘ARR’ of size ‘N x 3’ having integers, where ‘N’ is the number of rows.
Your task is to find the smallest sum possible while taking one element from each row.
The ...read more
Given an array of numbers, find the maximum sum of any contiguous subarray of the array.
For example, given the array [34, -50, 42, 14, -5, 86], the maximum sum would be 137, since we would ...read more
You are given the height of N people standing in a queue in an array 'HEIGHT'. For each person, you need to calculate the number of people on the right side of the given person...read more
You are given a binary search tree of integers with N nodes. You are also given references to two nodes P and Q from this BST.
Your task is to find the lowest common ancestor(LCA) of these two given...read more
You have been given a Binary Tree of ‘N’ nodes, where the nodes have integer values. Your task is to print all nodes that don’t have a sibling node.
Note:
1. Node ‘U’ is said to be a sibling of nod...read more
You are given an arithmetic expression in Reverse Polish Notation in the form of an array ‘EXP’. Your task is to evaluate the value of the given expression.
Reverse Polish Notati...read more
You have been given a MATRIX of non-negative integers of size N x M where 'N' and 'M' denote the number of rows and columns, respectively.
Your task is to find the length o...read more
You have been given a circular path. There are 'N' petrol pumps on this path that are numbered from 0 to N - 1 (Both inclusive). Each petrol pump has two values associated with it:
1)The amount of p...read more
Aragorn is a great ruler and desires to become the most powerful in the entire world. There are ‘N’ kingdoms, kingdoms are numbered from 0 to 'N' - 1 and form of a tree, you are also giv...read more
You have been given an undirected graph of ‘V’ vertices (labeled 0,1,..., V-1) and ‘E’ edges. Each edge connecting two nodes (‘X’,’Y’) will have a weight denoting the distance between node ...read more
You are given a list/array of strings which denotes the contacts that exist in your phone directory. The search query on a string ‘str’ which is a query string displays all the contac...read more
You are given an array 'ARR' of positive integers, each of which represents the number of liters of water in that particular bucket, we have to make the liters of water in every bucket equal.
We are allowe...read more
You are given an array/list 'ARR' of integers of length ‘N’. You are supposed to find all the elements that occur strictly more than floor(N/3) times in the given array/list.
Input Format :...read more
You are Harshad Mehta’s friend. He told you the price of a particular stock for the next ‘N’ days. You can either buy or sell a stock. Also, you can only complete at most 2-transactions. Find ...read more
You are given an array/list ARR consisting of N integers. Your task is to find all the distinct triplets present in the array which adds up to a given number K.
An array ...read more
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 bina...read more
You have been given two arrays, 'AT' and 'DT', representing the arrival and departure times of all trains that reach a railway station.
Your task is to find the minimum number of plat...read more
Given an array of ‘n’ integers arr. Find the Peak element of the array. The peak element of an array is defined as that element which is greater than both of its neighbours. I.e if arr[i] is th...read more
Given a binary tree, print its bottom view from left to right. Assume, the left and the right child make a 45-degree angle with the parent.
A binary tree is a tree in which each parent...read more
You have been given an array 'ARR' of ‘N’ integers. You have to find the minimum number of jumps needed to reach the last index of the array i.e ‘N - 1’ if at any index ‘i’ we can jump to an index ‘i +...read more
You have been given a sorted (lexical order) dictionary of an alien language. Write a function that finds the order of characters in the alien language. This dictionary will be given to you in t...read more
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 fo...read more
Given a binary tree, convert this binary tree into its mirror tree.
A binary tree is a tree in which each parent node has at most two children.
Mirror of a Tree: Mirror...read more
You are given a binary tree with 'N' nodes. Your task is to return the size of the largest subtree of the binary tree which is also a BST.
A binary search tree...read more
Given three strings A, B and C, the task is to find the length of the longest common sub-sequence in all the three strings A, B and C.
A subsequence of a string is a new string generated fro...read more
You have been given a linked list of integers. Your task is to write a function that deletes a node from a given position, 'POS'.
Note :
Assume that the Indexing for the linked lis...read more
Given a singly linked list of integers. Your task is to return the head of the reversed linked list.
For example:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked lis...read more
There is a one-dimensional garden of length 'N'. On each of the positions from 0 to 'N', there is a fountain, and this fountain’s water can reach up to a certain range as explained further. In ...read more
Given an array/list of integer numbers 'CHOCOLATES' of size 'N', where each value of the array/list represents the number of chocolates in the packet. There are ‘M’ number of students and the t...read more
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 are...read more
Given ‘a’ balls of type ‘A’, ‘b’ balls of type ‘B’ and ‘c’ balls of type ‘C’. You need to find the total number of ways to arrange the balls in a straight line such that adjacent balls are ...read more
You are given a single non-negative integer ‘N’ who’s binary representation consists of a single ‘1’ digit and the rest of the digits are ‘0’s. Your task is to find the position of the only...read more
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 data st...read more
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 data...read more
Mislabeled Jars :
There are 3 jars, namely, A, B, C. All of them are mislabeled. Following are the labels of each of the jars:
A: Candies
B: Sweets
C: Candies and Sweets (mixed in a random proportion)
You can ...read more
You have been given a binary tree of integers.
Your task is to check if it is a binary heap tree or not.
Note:
A binary tree is a tree in which each parent node has at most two children. A bi...read more
You are given an array of n integers (a1, a2,....,an), you need to find if the array contains a pythagorean triplet or not.
An array is said to have a pythagorean triplet if there exists thr...read more
You have been given an array 'PRICES' consisting of 'N' integers where PRICES[i] denotes the price of a given stock on the i-th day. You are also given an integer 'K' denoting the...read more
Prateek is a kindergarten teacher. He wants to give some candies to the children in his class. All the children stand in a line and each of them has a grade according to his or her performance in the cla...read more
You have been given a binary tree of integers with N number of nodes. Your task is to check if that input tree is a BST (Binary Search Tree) or not.
A binary search tree (BST) is a binary tree data ...read more
1. What concepts do you know about OOPS?
2. Implement Runtime polymorphism and Compile time polymorphism.
3. What are virtual functions?
4. Write a Copy constructor for a derived class?
5. He made some changes in ...read more
First he started by asking what is the `<<` operator in C++ in the statement `cout << "string";` and what is the concept used here. Then he asked for more examples of operator overloading.
He ...read more
Q60. 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 moreNo, 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.
You have been given an integer array/list(ARR) of size N which contains numbers from 0 to (N - 2). Each number is present at least once. That is, if N = 5, the array/list constitutes values rangin...read more
You have been given an array of integers 'ARR' and an integer ‘K’. You need to find the first negative integer in each window of size ‘K’.
Note :
If a window do...read more
Prateek is a kindergarten teacher. He wants to give some candies to the children in his class. All the children stand in a line and each of them has a grade according to his or her performance in...read more
You have been given a Binary Tree of 'N' nodes, where the nodes have integer values. Your task is to find the In-Order traversal of the given binary tree.
For e...read more
You are given two arrays 'A' and 'B' of size 'N' and 'M' respectively. Both these arrays are sorted in non-decreasing order. You have to find the intersection of these two a...read more
You are given a sorted array of ‘N’ distinct integers that are in the Arithmetic Progression sequence except for one element which is missing from the sequence. You have ...read more
You have been given a binary tree of 'N' unique nodes and a Start node from where the tree will start to burn. Given that the Start node will always exist in the tree, your task is to print the...read more
'N' students are standing in a row. You are given the height of every student standing in the row. Your task is to find the longest strictly increasing subsequence of heights from ...read more
Q69. In some tournament 139 teams have participated. Tournament is knock out. what is the number of matches to choose the champion to be held?
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.
Write a program to count the number of 1's in the binary representation of an integer.
Input format :
The only line of input contains a single integer N.
Output format :
The only line of the output pr...read more
What is Diamond Problem in C++ and how do we fix it?
There are 25 horses. We are allowed to conduct multiple races among the horses and based on the result, we need to find the fastest 5 horses among them. Find what is the minimum number of races to be orga...read more
Q73. What is the difference between default and copy constructor?
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
Q74. What is the difference between primary key and unique key?
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.
Q75. What is the difference between Truncate and Delete?
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.
There are 2 jugs with 4 litres and 5 litres of water respectively. The objective is to pour exactly 7 litres of water in a bucket. How can it be accomplished?
Q77. Write an algorithm to find the absolute max subsequence of an array containing both positive and negative numbers in O(n) time ?
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
What are the different types of semaphores ?
What is meant by Garbage Collection in OOPs world?
Q80. Design a class which has director, HOD, Professor and students. They all are reporting to their respective heads. I have to display the hierarchy structure of the information in a Site
Design a class hierarchy for director, HOD, Professor and students reporting to their respective heads.
Create a base class for all employees with common attributes and methods
Create derived classes for director, HOD, Professor and students
Implement reporting hierarchy using pointers or references
Display hierarchy structure on the site using a tree or graph
Consider adding additional attributes and methods as needed
Q81. What is the difference between C and C++?
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.
What are the types of access modifiers in C++?
Q83. Find the next largest int of a given int such that it has same number of 1′s in binary?
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.
Q84. What is the difference between DML and DLL?
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.
Q85. What is the difference between DBMS and RDBMs?
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
Q86. 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
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.
Q87. Given an array eliminate the duplicates and print it. Linear time complexity?
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
Q88. Mention any five operating systems which have been derived from UNIX
Five operating systems derived from UNIX are...
Linux
macOS
Solaris
FreeBSD
Android
How is Java platform independent?
What are the objectives of Normalization?
What is Daemon Process?
Write SQL Query to find employee with nth highest salary.
Q93. do you think the era of social media influencers is short lived?
No, social media influencers are here to stay.
Social media has become an integral part of our lives and will continue to be so.
Influencers have a huge impact on consumer behavior and brand marketing.
The industry is constantly evolving and adapting to changes.
Influencers are diversifying their content and expanding their reach.
Brands are investing more in influencer marketing than ever before.
Examples: Kylie Jenner, PewDiePie, Huda Kattan, etc.
Q94. What is the purpose of Normalisation?
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
Q95. How would I defend myself if I were to get caught for having downloaded torrents?
Defending oneself for downloading torrents
Explain that downloading torrents is illegal but common
Admit to the mistake and show remorse
Explain that you were not aware of the consequences
Promise to delete all downloaded content and not repeat the mistake
Offer to pay any fines or penalties
Consult a lawyer for legal advice
Explain select() system call.
Internal fragmentation v/s external fragmentation.
Q99. What are class access modifiers?
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
Define Process and Threads in OS
More about working at DE Shaw
Top HR Questions asked in null
Interview Process at null
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month