[Link].
io
60+
Must Do Coding Questions
Before the Interview (Blind 75)
for
Prepared by Design Gurus
[Link]
One-Stop Portal For Tech Interviews.
[Link]
Question 1
Two Sum Easy
Given an array of integers nums and an integer target. Find two
distinct indices i and j such that the sum of nums[i] and nums[j] is
equal to the target.
Solve now See Solution
Question 2
Contains Duplicate Easy
Given an integer array nums, return true if any value appears at
least twice in the array, and return false if every element is
distinct.
Solve now See Solution
[Link]
One-Stop Portal For Tech Interviews.
[Link]
Question 3
Best Time To Buy And Sell Stock Easy
Given an array prices where prices[i] is the price of a given
stock on the ith day.
You want to maximize your profit by choosing a single day to buy
one stock and choosing a different day in the future to sell that
stock.
Return the maximum profit you can achieve from this transaction.
If you cannot achieve any profit, return 0.
Solve now
Question 4
Valid Anagram Medium
Given two strings s and t, return true if t is an anagram of s, and
false otherwise.
An Anagram is a word or phrase formed by rearranging the letters
of a different word or phrase, typically using all the original letters
exactly once.
Solve now
[Link]
One-Stop Portal For Tech Interviews.
[Link]
Question 5
Valid Parentheses Medium
Determine if an input string containing only the characters '(', ')',
'{', '}', '[', and ']' is valid. A string is considered valid if:
1. Open brackets must be closed by the same type of brackets.
2. Open brackets must be closed in the correct order.
3. Each close bracket has a corresponding open bracket of the
same type.
Solve now
Question 6
Maximum Sum Subarray Of Size K Medium
Given an array of positive numbers and a positive number 'k,' find
the maximum sum of any contiguous subarray of size 'k'.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 7
Product Of Array Except Self Medium
Given an array of integers, return a new array where each
element at index i of the new array is the product of all the
numbers in the original array except the one at I
.
You must solve this problem without using division.
Solve now
Question 8
Triplet Sum To Zero Medium
Given an array of unsorted numbers, find all unique triplets in it
that add up to zero.
Solve now
[Link]
One-Stop Portal For Tech Interviews.
[Link]
Question 9
Merge Intervals Medium
Given a list of intervals, merge all the overlapping intervals to
produce a list that has only mutually exclusive intervals.
Solve now
Question 10
Group Anagrams Medium
Given a list of strings, the task is to group the anagrams together.
An anagram is a word or phrase formed by rearranging the letters
of another, such as "cinema", formed from "iceman".
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 11
Maximum Product Subarray Medium
Given an integer array, find the contiguous subarray (at least one
number in it) that has the maximum product. Return this maximum
product.
Solve now
Question 12
Find Minimum In Rotated Sorted Array Medium
Given an array of numbers which is sorted in ascending order and
also rotated by some arbitrary number, find if a given ‘key’ is
present in it.
Write a function to return the index of the ‘key’ in the rotated
array. If the ‘key’ is not present, return -1. You can assume that
the given array does not have any duplicates.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 13
Reverse A LinkedList Easy
Given the head of a Singly LinkedList, reverse the LinkedList.
Write a function to return the new head of the reversed
LinkedList.
Solve now
Question 14
LinkedList Cycle Easy
Given the head of a Singly LinkedList, write a function to
determine if the LinkedList has a cycle in it or not.
Solve now
Course Offered by Design Gurus
Grokking the Coding Grokking Data Structures
Interview for Coding Interviews
Learn More Learn More
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 15
Longest Repeating Character Replacement Medium
Given a string with lowercase letters only, if you are allowed to
replace no more than ‘k’ letters with any letter, find the length of
the longest substring having the same letters after replacement.
Solve now
Question 16
Container With Most Water Medium
Given an array of non-negative integers, where each integer
represents the height of a vertical line positioned at index I
.
You need to find the two lines that, when combined with the x-
axis, form a container that can hold the most water.
The goal is to find the maximum amount of water (area) that this
container can hold.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 17
Longest Substring Without Repeating Characters Medium
Given a string s, return the maximum number of unique
substrings that the given string can be split into.
You can split string s into any list of non-empty substrings, where
the concatenation of the substrings forms the original string.
However, you must split the substrings such that all of them are
unique.
A substring is a contiguous sequence of characters within a
string.
Solve now
Question 18
Find Minimum In Rotated Sorted Array Medium
You have an array of length n, which was initially sorted in
ascending order. This array was then rotated x times. It is given
that 1 <= x <= n. For example, if you rotate [1, 2, 3, 4] array 3
times, resultant array is [2, 3, 4, 1].
Your task is to find the minimum element from this array. Note
that the array contains unique elements.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 19
Remove Nth Node From End Of List Medium
Given a linked list, remove the last nth node from the end of the
list and return the head of the modified list.
Solve now
Question 20
Number Of Islands Medium
Given a 2D array (i.e., a matrix) containing only 1s (land) and 0s
(water), count the number of islands in it.
An island is a connected set of 1s (land) and is surrounded by
either an edge or 0s (water). Each cell is considered connected to
other cells horizontally or vertically (not diagonally).
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 21
Minimum Window Sort Medium
Given an array, find the length of the smallest subarray in it which
when sorted will sort the whole array.
Solve now
Question 22
Pacific Atlantic Water Flow Medium
Given a matrix m x n that represents the height of each unit cell
in a Island, determine which cells can have water flow to both the
Pacific and Atlantic oceans. The Pacific ocean touches the left
and top edges of the continent, while the Atlantic ocean touches
the right and bottom edges.
From each cell, water can only flow to adjacent cells (top, bottom,
left, or right) if the adjacent cell's height is less than or equal to
the current cell's height.
We need to return a list of grid coordinates where water can flow
to both the Pacific and Atlantic oceans.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 23
Invert Binary Tree Easy
Given the root of a binary tree, invert it.
Solve now
Question 24
Palindromic Substrings Medium
Given a string, determine the number of palindromic substrings
present in it.
A palindromic substring is a sequence of characters that reads
the same forwards and backward. The substring can be of any
length, including 1.
Solve now
[Link]
One-Stop Portal For Tech Interviews.
[Link]
Question 25
Validate Binary Search Tree Medium
Determine if a given binary tree is a binary search tree (BST). In
a BST, for each node:
All nodes to its left have values less than the node's value.
All nodes to its right have values greater than the node's
value.
Solve now
Question 26
Insert Interval Medium
Given a list of non-overlapping intervals sorted by their start time,
insert a given interval at the correct position and merge all
necessary intervals to produce a list that has only mutually
exclusive intervals.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 27
Construct Binary Tree from Preorder Medium
and Inorder Traversal
Given the preorder and inorder traversal sequences of a binary
tree, your task is to reconstruct this binary tree. Assume that the
tree does not contain duplicate values.
Solve now
Question 28
Top 'K' Frequent Numbers Medium
Given an unsorted array of numbers, find the top ‘K’ frequently
occurring numbers in it.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 29
Clone Graph Medium
Given a reference of a node in a connected undirected graph,
return a deep copy (clone) of the graph. Each node in the graph
contains a value (int) and a list (List[Node]) of its neighbors.
Solve now
Question 30
Tasks Scheduling Medium
There are ‘N’ tasks, labeled from ‘0’ to ‘N-1’. Each task can have
some prerequisite tasks which need to be completed before it can
be scheduled. Given the number of tasks and a list of prerequisite
pairs, find out if it is possible to schedule all the tasks.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 31
Serialize And Deserialize Binary Tree Hard
Given a binary tree, your task is to create two functions.
one for serializing the tree into a string format and another for
deserializing the string back into the tree.
The serialized string should retain all the tree nodes and their
connections, allowing for reconstruction without any loss of data.
Solve now
Question 32
Path With Maximum Sum Hard
Find the path with the maximum sum in a given binary tree. Write
a function that returns the maximum sum.
A path can be defined as a sequence of nodes between any
two nodes and doesn’t necessarily pass through the root. The
path must contain at least one node.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 33
Maximum Depth of Binary Tree Easy
Determine the depth (or height) of a binary tree, which refers to
the number of nodes along the longest path from the root node to
the farthest leaf node. If the tree is empty, the depth is 0.
Solve now
Question 34
Same Tree Easy
Given the roots of two binary trees 'p' and 'q', write a function to
check if they are the same or not.
Two binary trees are considered the same if they met following
two conditions:
1. Both tree are structurally identical.
2. Each corresponding node on both the trees have the same
value.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 35
Binary Tree Level Order Traversal Medium
Given a binary tree, populate an array to represent its level-by-
level traversal. You should populate the values of all nodes of
each level from left to right in separate sub-arrays.
Solve now
Question 36
Encode And Decode Strings Medium
Given a list of strings, your task is to develop two functions: one
that encodes the list of strings into a single string, and another
that decodes the resulting single string back into the original list
of strings. It is crucial that the decoded list is identical to the
original one.
It is given that you can use any encoding technique to encode list
of string into the single string.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 37
Subtree Of Another Tree Easy
Given two binary trees s and t, determine if tree t is a subtree of
tree s.
A tree t is considered a subtree of s if there exists a node in s
such that the subtree of that node is identical to t. Both trees are
considered identical if their structure and nodes are the same.
Solve now
Question 38
Lowest Common Ancestor of BST Medium
Given a binary search tree (BST) and two of its nodes, find the
node that is the lowest common ancestor (LCA) of the two given
nodes.
The LCA of two nodes is the node that lies in between the two
nodes in terms of value and is the furthest from the root.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 39
Implement Trie Medium
Design and implement a Trie (also known as a Prefix Tree).
A trie is a tree-like data structure that stores a dynamic set of
strings, and is particularly useful for searching for words with a
given prefix. Implement the following methods:
insert: Add a word to the trie.
search: Determine if the word exists in the trie.
startsWith: Determine if any word in the trie starts with the
given prefix.
Solve now
Question 40
Add and Search Word Medium
Design a data structure that allows you to:
1. Add a word.
2. Search for a word that can include dots ('.') as wildcards,
where the dot represents any single character.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 41
Kth Smallest Number Medium
Given an unsorted array of numbers, find Kth smallest number
in it.
Please note that it is the Kth smallest number in the sorted order,
not the Kth distinct element.
Solve now
Question 42
Insert Interval Medium
Given a list of non-overlapping intervals sorted by their start time,
insert a given interval at the correct position and merge all
necessary intervals to produce a list that has only mutually
exclusive intervals.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 43
Merge K Sorted Lists Hard
Given an array of ‘K’ sorted LinkedLists, merge them into one
sorted list.
Solve now
Question 44
Find Median from Data Stream Hard
Design a class to calculate the median of a number stream. The
class should have the following two methods:
1. insertNum(int num): stores the number in the class
2. findMedian(): returns the median of all numbers inserted in
the class
If the count of numbers inserted in the class is even, the median
will be the average of the middle two numbers.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 45
Minimum Meeting Rooms Easy
Given a list of intervals representing the start and end time of ‘N’
meetings, find the minimum number of rooms required to hold
all the meetings.
Solve now
Question 46
Longest Consecutive Sequence Medium
Given an unsorted array of integers, find the length of the
longest consecutive sequence of numbers in it.
A consecutive sequence means the numbers in the sequence are
contiguous without any gaps. For instance, 1, 2, 3, 4 is a
consecutive sequence, but 1, 3, 4, 5 is not.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 47
Word Search Hard
Given an m x n grid of characters board and a string word, return
true if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent
cells, where adjacent cells are horizontally or vertically
neighboring. The same letter cell may not be used more than
once.
Solve now
Question 48
Alien Dictionary Hard
There is a dictionary containing words from an alien language for
which we don’t know the ordering of the letters.
Write a method to find the correct order of the letters in the alien
language.
It is given that the input is a valid dictionary and there exists an
ordering among its letters.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 49
Meeting Rooms II Medium
Given a list of time intervals during which meetings are
scheduled, determine the minimum number of meeting rooms
that are required to ensure that none of the meetings overlap in
time.
Solve now
Question 50
Graph Valid Tree Medium
Given a number n, which indicates the number of nodes
numbered from 0 to n-1, and a list of undirected edges for the
graph, determine if the graph is a valid tree.
A graph qualifies as a valid tree if it meets the following criteria:
1. It has no cycles.
2. It is fully connected.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 51
Climbing Stairs Easy
Given a stair with 'n' steps, implement a method to count how
many possible ways are there to reach the top of the staircase,
given that, at every step you can either take 1 step, 2 steps, or 3
steps.
Solve now
Question 52
Number of Connected Components
Medium
in an Undirected Graph
Given an unsorted array of integers, find the length of the longest
consecutive sequence of numbers in it.
A consecutive sequence means the numbers in the sequence are
contiguous without any gaps. For instance, 1, 2, 3, 4 is a
consecutive sequence, but 1, 3, 4, 5 is not.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 53
Coin Change Medium
Given an infinite supply of ‘n’ coin denominations and a total
money amount, we are asked to find the total number of distinct
ways to make up that amount.
Solve now
Question 54
Longest Increasing Subsequence Medium
Given a number sequence, find the length of its Longest
Increasing Subsequence (LIS). In an increasing subsequence, all
the elements are in increasing order (from lowest to highest).
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 55
Combination Sum Medium
Given an array of distinct positive integers candidates and a
target integer target, return a list of all unique combinations of
candidates where the chosen numbers sum to target. You may
return the combinations in any order.
The same number may be chosen from candidates an unlimited
number of times. Two combinations are unique if the frequency of
at least one of the chosen numbers is different.
Solve now
Question 56
House Thief Medium
Given a number array representing the wealth of n houses,
determine the maximum amount of money the thief can steal
without alerting the security system.
Solve now
Design Gurus
One-Stop Portal For Tech Interviews.
[Link]
Question 57
House Robber II Medium
You are given an array representing the amount of money each
house has. This array models a circle of houses, meaning that the
first and last houses are adjacent. You are tasked with figuring
out the maximum amount of money you can rob without alerting
the neighbors.
The rule is: if you rob one house, you cannot rob its adjacent
houses.
Solve now
Question 58
Decode Ways Medium
You have given a string that consists only of digits. This string
can be decoded into a set of alphabets where '1' can be
represented as 'A', '2' as 'B', ... , '26' as 'Z'.
The task is to determine how many ways the given digit string can
be decoded into alphabets.
Solve now
[Link]
One-Stop Portal For Tech Interviews.
[Link]
Question 59
Unique Paths Medium
You are given an array representing the amount of money each
house has. This array models a circle of houses, meaning that the
first and last houses are adjacent. You are tasked with figuring
out the maximum amount of money you can rob without alerting
the neighbors.
The rule is: if you rob one house, you cannot rob its adjacent
houses.
Solve now
Question 60
Minimum Jumps To Reach The End Medium
Given an array of positive numbers, where each element
represents the max number of jumps that can be made forward
from that element, write a program to find the minimum number of
jumps needed to reach the end of the array (starting from the first
element).
If an element is 0, then we cannot move through that element.
Solve now
[Link]
One-Stop Portal For Tech Interviews.
[Link]
Question 61
Word Break Medium
Given a non-empty string and a dictionary containing a list of non-
empty words, determine if the string can be segmented into a
space-separated sequence of one or more dictionary words.
Each word in the dictionary can be reused multiple times.
Solve now
See Solution of All Questions
Course Offered by Design Gurus
Grokking the Coding Grokking Data Structures
Interview for Coding Interviews
Learn More Learn More
[Link]
One-Stop Portal For Tech Interviews.