30+ Supercoder Interview Questions and Answers
Q1. Optimal BST Problem Statement
You are given a sorted array representing keys of a BST and an array of frequency counts showing how often each key is searched. Your task is to construct a binary search tree (BST...read more
Q2. Stock Trading Maximum Profit Problem
Given the stock prices for 'N' days, your goal is to determine the maximum profit that can be achieved. You can buy and sell the stocks any number of times but can only hold...read more
Q3. Find The Repeating And Missing Number Problem Statement
You are provided with an array nums
which contains the first N positive integers. In this array, one integer appears twice, and one integer is missing. Yo...read more
Q4. Optimal Strategy for a Coin Game
You are playing a coin game with your friend Ninjax. There are N
coins placed in a straight line.
Here are the rules of the game:
1. Each coin has a value associated with it.
2....read more
Q5. Number of Distinct Substrings Problem Statement
Given a string WORD
containing lowercase English alphabets and having length N
, determine the number of distinct substrings in WORD
.
Input:
The first line include...read more
Q6. Counting Triangles in Graphs
Given two graphs – a directed graph DIR_GRAPH
and an undirected graph UNDIR_GRAPH
– you are tasked with counting the number of triangles in each of the graphs.
Example:
In the examp...read more
Q7. Find Distinct Palindromic Substrings
Given a string 'S', identify and print all distinct palindromic substrings within it. A palindrome reads the same forwards and backwards. For example, 'bccb' is a palindrome...read more
Q8. Distance Between Two Nodes in a Binary Tree
Given a binary tree and the values of two distinct nodes, determine the distance between these two nodes in the tree. The distance is defined as the minimum number of...read more
Q9. Bit Majority Number Generation
You are given an array arr
consisting of N
integers. Construct a number from these integers such that, for each bit position, if the quantity of set bits (1s) is greater than the ...read more
Q10. Shuffle Two Strings
You are provided with three strings: A
, B
, and C
. Your task is to determine if C
is formed by interleaving A
and B
. A string C
is considered an interleaving of A
and B
if:
- The length of
C
i...read more
Q11. Stack with getMin Operation
Create a stack data structure that supports not only the usual push and pop operations but also getMin(), which retrieves the minimum element, all in O(1) time complexity without usi...read more
Q12. Ninja's Complement Problem Statement
Every day, Ninja dreams of a number but does not understand its significance. Upon investigation, Ninja discovers that converting this number to binary, taking its complemen...read more
Q13. Sum of Digits Problem Statement
Given an integer 'N', continue summing its digits until the result is a single-digit number. Your task is to determine the final value of 'N' after applying this operation iterat...read more
Q14. 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
Q15. Ninja and Sorted Array Merging Problem
Ninja is tasked with merging two given sorted integer arrays ARR1
and ARR2
of sizes 'M' and 'N', respectively, such that the merged result is a single sorted array within ...read more
Q16. Binary Tree to Doubly Linked List
Transform a given Binary Tree into a Doubly Linked List.
Ensure that the nodes in the Doubly Linked List follow the Inorder Traversal of the Binary Tree.
Input:
The first line ...read more
Q17. 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
Q18. Word Distance Calculation
Given a document represented as an array/list ARR
of words with length N
, find the smallest distance between two given words for multiple queries. The distance is defined as the differ...read more
Q19. Decode Ways Problem Statement
Given a string strNum
that represents a number, the task is to determine the number of ways to decode it using the following encoding: 'A' - 1, 'B' - 2, ..., 'Z' - 26.
Input:
The f...read more
Q20. Longest Palindromic Subsequence Problem Statement
Given a string A
consisting of lowercase English letters, determine the length of the longest palindromic subsequence within A
.
Explanation:
- A subsequence is d...read more
Q21. Serialize and Deserialize Binary Tree Problem Statement
Given a binary tree of integers, your task is to implement serialization and deserialization methods. You can choose any algorithm for serialization and d...read more
Q22. Level Order Traversal Problem Statement
Given a binary tree of integers, return the level order traversal of the binary tree.
Input:
The first line contains an integer 'T', representing the number of test cases...read more
Q23. Combination Sum Problem Statement
Given an array of distinct positive integers ARR
and a non-negative integer 'B', find all unique combinations in the array where the sum is equal to 'B'. Numbers can be chosen ...read more
Q24. Palindrome Permutation - Problem Statement
Determine if a permutation of a given string S
can form a palindrome.
Example:
Input:
string S = "aab"
Output:
"True"
Explanation:
The permutation "aba" of the string ...read more
Q25. Number of Islands Problem Statement
You are given a non-empty grid that consists of only 0s and 1s. Your task is to determine the number of islands in this grid.
An island is defined as a group of 1s (represent...read more
Q26. Generate All Parentheses Combinations
Given an integer N
, your task is to create all possible valid parentheses configurations that are well-formed using N
pairs. A sequence of parentheses is considered well-fo...read more
Interview Process at Supercoder
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month