Coding Questions
Coding Questions
Coding Problem
1
Arrays
Given an array of integers and an integer target, return indices of the
two numbers such that they add up to target.
Asked in :
Practice
Given an integer array nums, find the subarray with the largest sum,
and return its sum.
Asked in :
Practice
Given an array nums with n objects colored red, white, or blue, sort
them in-place so that objects of the same color are adjacent, with
the colors in the order red, white, and blue.
Asked in :
Practice
2
Given an array nums of n integers, return an array of all the unique
quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:
0 <= a, b, c, d < n
Practice
3
Strings
Given a string s of '(' , ')' and lowercase English characters.
Practice
Return the sorted string. If there are multiple answers, return any of
them.
Asked in :
Practice
4
Given two strings s1 and s2, return true if s2 contains a permutation
of s1, or false otherwise.
Practice
Practice
Practice
5
Recursion
Given the head of a linked list and an integer val, remove all the
nodes of the linked list that has Node.val == val, and return the new
head.
Asked in :
Practice
Given the head of a singly linked list, reverse the list, and return the
reversed list.
Asked in :
Practice
The solution set must not contain duplicate subsets. Return the
solution in any order
Asked in :
Practice
6
Given n pairs of parentheses, write a function to generate all
combinations of well-formed parentheses.
Asked in :
Practice
7
Hashing
Design a data structure that follows the constraints of a Least
Recently Used (LRU) cache.
Asked in :
Practice
You must implement an algorithm that runs in O(n) time and uses
constant extra space.
Asked in :
Practice
8
Matrices
Given an m x n matrix, return all elements of the matrix in spiral order.
Asked in :
Practice
Each of the nine 3 x 3 sub-boxes of the grid must contain the digits
1-9 without repetition.
Asked in :
Practice
Practice
9
Linked List
Given the root of a binary tree, flatten the tree into a "linked list":
The "linked list" should use the same TreeNode class where the right
child pointer points to the next node in the list and the left child
pointer is always null.
Practice
Practice
10
Given the head of a linked list, reverse the nodes of the list k at a
time, and return the modified list. k is a positive integer and is less
than or equal to the length of the linked list. If the number of nodes is
not a multiple of k then left-out nodes, in the end, should remain as it
is.
You may not alter the values in the list's nodes, only nodes
themselves may be changed.
Asked in :
Practice
You are given the heads of two sorted linked lists list1 and list2.
Merge the two lists in a one sorted list. The list should be made by
splicing together the nodes of the first two lists.
Asked in :
Practice
11
You are given two non-empty linked lists representing two non-
negative integers. The digits are stored in reverse order, and each of
their nodes contains a single digit. Add the two numbers and return
the sum as a linked list.
You may assume the two numbers do not contain any leading zero,
except the number 0 itself.
Asked in :
Practice
Given a linked list, swap every two adjacent nodes and return its
head. You must solve the problem without modifying the values in
the list's nodes (i.e., only nodes themselves may be changed.)
Asked in :
Practice
12
Bit Manipulation and Math
Given an array nums containing n distinct numbers in the range [0,
n], return the only number in the range that is missing from the array.
Asked in :
Practice
Practice
13
Stacks and Queues
Given an array of integers heights representing the histogram's bar
height where the width of each bar is 1, return the area of the largest
rectangle in the histogram.
Asked in :
Practice
Design a stack that supports push, pop, top, and retrieving the
minimum element in constant time.
Asked in :
Practice
Practice
14
Implement the BSTIterator class that represents an iterator over the
in-order traversal of a binary search tree (BST)
Asked in :
Practice
Practice
15
Trees and Binary Search Trees
Given the root of a binary tree, return its maximum depth.
Given a binary tree, find the lowest common ancestor (LCA) of two
given nodes in the tree.
Asked in :
Practice
Given the root of a binary search tree, and an integer k, return the
kth smallest value (1-indexed) of all the values of the nodes in the
tree.
Asked in :
Practice
16
Given the root of a binary tree, return the level order traversal of its
nodes' values. (i.e., from left to right, level by level).
Asked in :
Practice
You are given the root of a binary tree containing digits from 0 to 9
only.
For example, the root-to-leaf path 1 -> 2 -> 3 represents the number
123.Return the total sum of all root-to-leaf numbers. Test cases are
generated so that the answer will fit in a 32-bit integer.
Asked in :
Practice
Given the roots of two binary trees root and subRoot, return true if
there is a subtree of root with the same structure and node values of
subRoot and false otherwise.
Asked in :
Practice
17
Tries
A trie (pronounced as "try") or prefix tree is a tree data structure
used to efficiently store and retrieve keys in a dataset of strings.
There are various applications of this data structure, such as
autocomplete and spellchecker.
Practice
Given an array of strings strs, group the anagrams together. You can
return the answer in any order.
Asked in :
Practice
18
Heaps
You are given an array of k linked-lists lists, each linked-list is sorted
in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
Asked in :
Practice
The median is the middle value in an ordered integer list. If the size of
the list is even, there is no middle value, and the median is the mean
of the two middle values.
Practice
19
Graphs
Given is a 2D adjacency list representation of a graph. Check
whether the graph is a Bipartite graph.
Asked in :
Practice
You are also given three integers sr, sc, and color. You should
perform a flood fill on the image starting from the pixel image[sr][sc].
Asked in :
Practice
Practice
20
Given a reference of a node in a connected undirected graph.
Asked in :
Practice
From each cell, you can either move in four directions: left, right, up,
or down. You may not move diagonally or move outside the boundary
(i.e., wrap-around is not allowed).
Asked in :
Practice
21
Dynamic Programming
Given an integer array nums, find a subarray that has the largest
product, and return the product.
Asked in :
Practice
Given two strings text1 and text2, return the length of their longest
common subsequence. If there is no common subsequence, return 0.
Asked in :
Practice
Given the two integers m and n, return the number of possible unique
paths that the robot can take to reach the bottom-right corner.
Asked in :
Practice
22
Why Bosscoder?
2200+ Alumni placed at Top Product-
based companies.
Explore More