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 Intern
Fresher
Skills
Clear (1)

20+ DE Shaw Software Developer Intern Interview Questions and Answers

Updated 5 Feb 2024

Q1. K Max Sum Combinations Problem Statement

Given two arrays/lists A and B, each of size N, and an integer K, you need to determine the K maximum and valid sum combinations from all possible combinations of sums g...read more

Ans.

The problem involves finding the K maximum sum combinations from two arrays by adding one element from each array.

  • Iterate through all possible sum combinations of elements from arrays A and B.

  • Store the sums in a max heap to keep track of the K maximum sums.

  • Pop the top K elements from the max heap to get the K maximum sum combinations.

Add your answer
right arrow

Q2. Water Equalization Problem Statement

You are provided with an array ARR of positive integers. Each integer represents the number of liters of water in a bucket. The goal is to make the liters of water in every ...read more

Ans.

Given an array of water buckets, find the minimum liters of water to remove to make all buckets equal.

  • Iterate through the array to find the maximum frequency of a water amount

  • Calculate the total liters to be removed by subtracting the maximum frequency from the total number of buckets

  • Return the total liters to be removed as the answer

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

Q3. Minimum Fountains Activation Problem

In this problem, you have a one-dimensional garden of length 'N'. Each position from 0 to 'N' has a fountain that can provide water to the garden up to a certain range. Thus...read more

Ans.

Find the minimum number of fountains to activate to water the entire garden.

  • Iterate through the array to find the coverage of each fountain.

  • Keep track of the farthest coverage reached by each activated fountain.

  • Activate the fountain that covers the farthest distance not yet covered.

  • Repeat until the entire garden is watered.

Add your answer
right arrow

Q4. Check if Binary Search Tree (BST)

Given a binary tree with 'N' nodes, verify whether this tree is a Binary Search Tree (BST). Return true if it is a BST and false otherwise.

Definition:

A Binary Search Tree (BS...read more

Ans.

Verify if a given binary tree is a Binary Search Tree (BST) or not.

  • Check if the left subtree of a node contains only nodes with values less than the node's value.

  • Check if the right subtree of a node contains only nodes with values greater than the node's value.

  • Ensure that both the left and right subtrees are also binary search trees.

  • Return true if the tree is a BST, false otherwise.

  • Handle cases with duplicate elements in either subtree.

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

Q5. Delete a Node from a Linked List

You are provided with a linked list of integers. Your task is to implement a function that deletes a node located at a specified position 'POS'.

Input:

The first line contains a...read more
Ans.

Implement a function to delete a node from a linked list at a specified position.

  • Traverse the linked list to find the node at the specified position.

  • Update the pointers of the previous and next nodes to skip the node to be deleted.

  • Handle cases where the position is at the beginning or end of the linked list.

  • Ensure to free the memory of the deleted node to avoid memory leaks.

Add your answer
right arrow

Q6. Reverse Linked List Problem Statement

Given a singly linked list of integers, return the head of the reversed linked list.

Example:

Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Ans.

Reverse a singly linked list of integers and return the head of the reversed linked list.

  • Iterate through the linked list and reverse the pointers to point to the previous node instead of the next node.

  • Use three pointers to keep track of the current, previous, and next nodes while reversing the linked list.

  • Update the head of the reversed linked list as the last node encountered during the reversal process.

Add your answer
right arrow
Are these interview questions helpful?

Q7. Ways To Make Coin Change

Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more

Ans.

The task is to find the total number of ways to make change for a specified value using given denominations.

  • Use dynamic programming to solve this problem efficiently.

  • Create a 2D array to store the number of ways to make change for each value up to the specified value.

  • Iterate through each denomination and update the array accordingly.

  • The final answer will be stored in the last cell of the array.

  • Example: For N=3, D=[1, 2, 3], V=4, the output is 4 as explained in the example.

Add your answer
right arrow

Q8. Ways to Arrange Balls Problem

You are given 'a' balls of type 'A', 'b' balls of type 'B', and 'c' balls of type 'C'. Determine the total number of ways to arrange these balls in a straight line so that no two a...read more

Ans.

The problem involves arranging balls of different types in a straight line without having two adjacent balls of the same type.

  • Use recursion to try all possible arrangements while keeping track of the previous ball type.

  • Handle edge cases where one or more types of balls have a count of 0.

  • Consider using dynamic programming to optimize the solution by storing intermediate results.

  • For the given example input (2 1 1), the output is 6 as there are 6 valid arrangements.

  • For the input...read more

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

Q9. Best Time To Buy and Sell Stock Problem Statement

You are given an array 'PRICES' of 'N' integers, where 'PRICES[i]' represents the price of a certain stock on the i-th day. An integer 'K' is also provided, ind...read more

Ans.

The task is to determine the maximum profit achievable with at most K transactions by buying and selling stocks.

  • Iterate through the array and keep track of the minimum price to buy and maximum profit for each transaction.

  • Use dynamic programming to store the maximum profit at each day with each possible number of transactions.

  • Consider edge cases like when K is 0 or when the array is empty.

  • Example: For input N = 6, PRICES = [3, 2, 6, 5, 0, 3], K = 2, the output would be 7.

Add your answer
right arrow

Q10. Find the Lone Set Bit

Your task is to identify the position of the only '1' bit in the binary representation of a given non-negative integer N. The representation contains exactly one '1' and the rest are '0's....read more

Ans.

Find the position of the only '1' bit in the binary representation of a given non-negative integer.

  • Iterate through the bits of the integer to find the position of the lone '1' bit.

  • Use bitwise operations to check if there is exactly one '1' bit in the binary representation.

  • Return the position of the lone '1' bit or -1 if there isn't exactly one '1'.

Add your answer
right arrow

Q11. Longest Common Subsequence of Three Strings

Given three strings A, B, and C, the task is to determine the length of the longest common subsequence across these three strings.

Explanation:

A subsequence of a str...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

Q12. 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 overall by considering different combinations of buy and sell points.

  • Consider edge cases where the stock prices ...read more

Add your answer
right arrow

Q13. Validate BST Problem Statement

Given a binary tree with N nodes, determine whether the tree is a Binary Search Tree (BST). If it is a BST, return true; otherwise, return false.

A binary search tree (BST) is a b...read more

Ans.

Validate if a binary tree is a Binary Search Tree (BST) or not.

  • Check if the left subtree of a node contains only nodes with data less than the node's data.

  • Check if the right subtree of a node contains only nodes with data greater than the node's data.

  • Ensure that both the left and right subtrees are also binary search trees.

  • Traverse the tree in an inorder manner and check if the elements are in sorted order.

  • Use recursion to validate each node and its subtrees.

Add your answer
right arrow

Q14. Longest Increasing Subsequence Problem Statement

Given 'N' students standing in a row with specific heights, your task is to find the length of the longest strictly increasing subsequence of their heights, ensu...read more

Ans.

Find the length of the longest strictly increasing subsequence of heights of students in a row.

  • Iterate through the heights array and for each student, find the length of the longest increasing subsequence ending at that student.

  • Use dynamic programming to keep track of the longest increasing subsequence length for each student.

  • Return the maximum length found in the dynamic programming array as the result.

  • Example: For heights [10, 20, 10, 30, 40], the longest increasing subsequ...read more

Add your answer
right arrow

Q15. First Negative Integer in Every Window of Size K

Given an array of integers 'ARR' and an integer 'K', determine the first negative integer in every contiguous subarray (or window) of size 'K'. If a window does ...read more

Ans.

Find the first negative integer in every window of size K in an array.

  • Iterate through the array using a sliding window approach of size K

  • For each window, find the first negative integer and add it to the result array

  • If no negative integer is found in a window, add 0 to the result array

Add your answer
right arrow

Q16. Pythagorean Triplets Detection

Determine if an array contains a Pythagorean triplet by checking whether there are three integers x, y, and z such that x2 + y2 = z2 within the array.

Input:

The first line contai...read more
Ans.

Detect if an array contains a Pythagorean triplet by checking if x^2 + y^2 = z^2.

  • Iterate through all possible triplets of numbers in the array and check if they form a Pythagorean triplet.

  • Use a nested loop to generate all possible combinations of three numbers from the array.

  • Check if the sum of squares of two numbers is equal to the square of the third number.

Add your answer
right arrow

Q17. Candies Distribution Problem Statement

Prateek is a kindergarten teacher with a mission to distribute candies to students based on their performance. Each student must get at least one candy, and if two student...read more

Ans.

The task is to distribute candies to students based on their performance while minimizing the total candies distributed.

  • Create an array to store the minimum candies required for each student.

  • Iterate through the students' ratings array to determine the minimum candies needed based on the adjacent ratings.

  • Consider both left-to-right and right-to-left passes to ensure fair distribution.

  • Calculate the total candies required by summing up the values in the array.

  • Example: For rating...read more

Add your answer
right arrow

Q18. Validate Binary Search Tree (BST)

You are given a binary tree with 'N' integer nodes. Your task is to determine whether this binary tree is a Binary Search Tree (BST).

BST Definition:

A Binary Search Tree (BST)...read more

Ans.

Validate if a given binary tree is a Binary Search Tree (BST) or not.

  • Check if the left subtree of a node contains only nodes with data less than the node's data

  • Check if the right subtree of a node contains only nodes with data greater than the node's data

  • Recursively check if both left and right subtrees are also binary search trees

Add your answer
right arrow

Q19. Find the Duplicate Number Problem Statement

Given an integer array 'ARR' of size 'N' containing numbers from 0 to (N - 2). Each number appears at least once, and there is one number that appears twice. Your tas...read more

Ans.

Find the duplicate number in an array of integers from 0 to (N-2).

  • Iterate through the array and keep track of the count of each number using a hashmap.

  • Return the number with a count greater than 1 as the duplicate number.

  • Alternatively, use Floyd's Tortoise and Hare algorithm to find the duplicate number in O(N) time and O(1) space.

Add your answer
right arrow

Q20. Count Ways to Reach the N-th Stair Problem Statement

You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two step...read more

Ans.

The problem involves counting the number of distinct ways to climb N stairs by taking 1 or 2 steps at a time.

  • Use dynamic programming to solve the problem efficiently.

  • The number of ways to reach the Nth stair is the sum of the number of ways to reach the (N-1)th stair and the (N-2)th stair.

  • Handle base cases where N=0 and N=1 separately.

  • Consider using modulo operation to avoid overflow when dealing with large numbers.

Add your answer
right arrow

Q21. Time to Burn Tree Problem

You are given a binary tree consisting of 'N' unique nodes and a start node where the burning will commence. The task is to calculate the time in minutes required to completely burn th...read more

Ans.

Calculate the time in minutes required to completely burn a binary tree starting from a given node.

  • Start burning from the given node and spread fire to adjacent nodes each minute

  • Track the time taken for each node to burn and return the maximum time taken

  • Use a queue to keep track of nodes to be burned next

Add your answer
right arrow

Q22. Candy Distribution Problem Statement

Prateek, a kindergarten teacher, needs to distribute candies to his class. Each child has a performance grade, and all students stand in a line.

The rules for distributing c...read more

Ans.

Calculate the minimum number of candies needed to distribute to students based on their performance grades.

  • Create an array to store the minimum candies needed for each student.

  • Iterate through the students' ratings from left to right, comparing each student with the previous one to determine the candy count.

  • Iterate through the students' ratings from right to left, comparing each student with the next one to ensure the correct candy count.

  • Sum up the total candies needed for all...read more

Add your answer
right arrow

Q23. Binary Ones Count Problem

Develop a program to determine the number of '1's in the binary form of a given integer.

Input:

The input consists of a single line containing an integer N.

Output:

The output should b...read more
Ans.

Count the number of '1's in the binary form of a given integer.

  • Convert the given integer to binary representation

  • Count the number of '1's in the binary representation

  • Return the count of '1's as output

Add your answer
right arrow

Q24. Equalize Water in Buckets

You are provided with an array, ARR, of positive integers. Each integer represents the number of liters of water in a bucket. The goal is to make the water volume in each bucket equal ...read more

Ans.

Find the minimum amount of water to be removed to equalize water in buckets.

  • Iterate through the array to find the average water level.

  • Calculate the total amount of water that needs to be removed to equalize the buckets.

  • Keep track of the excess water in each bucket and sum them up to get the final result.

Add your answer
right arrow
Q25. You have two wires of different lengths that are both capable of burning for exactly one hour when ignited at both ends. How can you measure a time interval of 45 minutes using these two wires?
Ans.

Use one wire to measure 30 minutes, then ignite the other wire at one end and the middle point to measure 15 minutes.

  • Ignite one wire at both ends and the other wire at one end. The first wire will burn out in 30 minutes.

  • At the same time, ignite the second wire at one end and the middle point. It will take 15 minutes for the fire to reach the middle point from one end.

  • When the first wire burns out, ignite the other end of the second wire. It will take another 15 minutes for th...read more

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 tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Intern Interview Questions from Similar Companies

View all
Recently Viewed
INTERVIEWS
Sherwin Williams Paints
No Interviews
INTERVIEWS
Sherwin Williams Paints
No Interviews
INTERVIEWS
Sherwin Williams Paints
No Interviews
INTERVIEWS
Sherwin Williams Paints
No Interviews
INTERVIEWS
TK Elevator
No Interviews
INTERVIEWS
Walmart
No Interviews
JOBS
Lowe's
No Jobs
SALARIES
Sherwin Williams Paints
INTERVIEWS
FLSmidth
No Interviews
INTERVIEWS
FLSmidth
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