Interview Question
Practice with our collection of real interview questions from top companies of your industry in a personalized mock interview experience.
Search question...
Company
Company
Company
Roles
Roles
Roles
Asked at
Google, Amazon, Goldman Sachs
You have three identical light bulbs in a windowless room, each connected to one of three switches outside. All bulbs are currently off. You can flip any of the switches only once before entering the room to identify which switch controls which bulb. How can you determine the correct switch for each bulb?
Medium
Case
Learn More
Practice with AI
Asked at
Google, Amazon, Goldman Sachs
You have three identical light bulbs in a windowless room, each connected to one of three switches outside. All bulbs are currently off. You can flip any of the switches only once before entering the room to identify which switch controls which bulb. How can you determine the correct switch for each bulb?
Medium
Case
Learn More
Practice with AI
Asked at
Write a program to sort a stack in ascending order, with the largest items on top. You may use only one additional stack for temporary storage, and you cannot use any other data structure (such as an array). The stack should support the following operations: push, pop, peek, and isEmpty
Hard
Coding
Learn More
Practice with AI
Asked at
Write a program to sort a stack in ascending order, with the largest items on top. You may use only one additional stack for temporary storage, and you cannot use any other data structure (such as an array). The stack should support the following operations: push, pop, peek, and isEmpty
Hard
Coding
Learn More
Practice with AI
Asked at
Google, Tesla, Microsoft
Write a method to sort an array of strings, grouping anagrams together
Medium
Coding
Learn More
Practice with AI
Asked at
Google, Tesla, Microsoft
Write a method to sort an array of strings, grouping anagrams together
Medium
Coding
Learn More
Practice with AI
Asked at
Amazon, Netflix, Apple
Write a function to solve the job scheduling problem that maximizes profit
Hard
Coding
Learn More
Practice with AI
Asked at
Amazon, Netflix, Apple
Write a function to solve the job scheduling problem that maximizes profit
Hard
Coding
Learn More
Practice with AI
Asked at
Google, Netflix, IBM
Write a function to find the longest substring without repeating characters in a given string
Medium
Coding
Learn More
Practice with AI
Asked at
Google, Netflix, IBM
Write a function to find the longest substring without repeating characters in a given string
Medium
Coding
Learn More
Practice with AI
Asked at
Amazon
Write a function to execute an inorder traversal of a binary tree
Medium
Coding
Learn More
Practice with AI
Asked at
Amazon
Write a function to execute an inorder traversal of a binary tree
Medium
Coding
Learn More
Practice with AI
Asked at
Microsoft, IBM, Google
Write a function to determine the longest univalue path in a binary tree
Hard
Coding
Learn More
Practice with AI
Asked at
Microsoft, IBM, Google
Write a function to determine the longest univalue path in a binary tree
Hard
Coding
Learn More
Practice with AI
Asked at
Intel
Write a function to determine if a given string is a valid palindrome
Easy
Coding
Learn More
Practice with AI
Asked at
Intel
Write a function to determine if a given string is a valid palindrome
Easy
Coding
Learn More
Practice with AI
Asked at
Netflix, Amazon
Write a function to determine if a given string is a permutation of a palindrome, where a palindrome reads the same forwards and backwards
Medium
Coding
Learn More
Practice with AI
Asked at
Netflix, Amazon
Write a function to determine if a given string is a permutation of a palindrome, where a palindrome reads the same forwards and backwards
Medium
Coding
Learn More
Practice with AI
Asked at
IBM, Netflix
Write a function to calculate the path sum in a binary tree
Medium
Coding
Learn More
Practice with AI
Asked at
IBM, Netflix
Write a function to calculate the path sum in a binary tree
Medium
Coding
Learn More
Practice with AI
Asked at
Netflix, Microsoft, Amazon
Write a function to calculate the number of distinct ways to construct a specified string
Medium
Coding
Learn More
Practice with AI
Asked at
Netflix, Microsoft, Amazon
Write a function to calculate the number of distinct ways to construct a specified string
Medium
Coding
Learn More
Practice with AI
Asked at
Apple
Write a function to calculate the maximum path sum in a binary tree
Hard
Coding
Learn More
Practice with AI
Asked at
Apple
Write a function to calculate the maximum path sum in a binary tree
Hard
Coding
Learn More
Practice with AI
Asked at
IBM
Write a function to calculate the maximum area of an island in a 2D grid
Hard
Coding
Learn More
Practice with AI
Asked at
IBM
Write a function to calculate the maximum area of an island in a 2D grid
Hard
Coding
Learn More
Practice with AI
Asked at
IBM, Amazon, Intel
Write a function to calculate the distance between two nodes in a binary tree
Medium
Coding
Learn More
Practice with AI
Asked at
IBM, Amazon, Intel
Write a function to calculate the distance between two nodes in a binary tree
Medium
Coding
Learn More
Practice with AI
Asked at
Tesla, Netflix
Write a function that calculates the sum of all nodes in a binary tree that have an even-valued grandparent
Hard
Coding
Learn More
Practice with AI
Asked at
Tesla, Netflix
Write a function that calculates the sum of all nodes in a binary tree that have an even-valued grandparent
Hard
Coding
Learn More
Practice with AI
Load 200+ Questions