Full Stack Developer
700+ Full Stack Developer Interview Questions and Answers
Popular Companies
Q1. Query and Matrix Problem Statement
You are given a binary matrix with 'M' rows and 'N' columns, initially consisting of all 0s. You will receive 'Q' queries, which can be of four types:
Query 1: 1 R index
Query ...read more
Given a binary matrix, perform queries to flip elements in rows/columns and count zeros in rows/columns.
Iterate through each query and update the matrix accordingly
For type 1 queries, flip the elements in the specified row/column
For type 2 queries, count the number of zeros in the specified row/column
Return the count of zeros for type 2 queries
Q2. Find Duplicates in an Array
Given an array ARR
of size 'N', where each integer is in the range from 0 to N - 1, identify all elements that appear more than once.
Return the duplicate elements in any order. If n...read more
The task is to find all duplicate elements in an array of integers.
Iterate through the array and keep track of the count of each element using a hashmap.
Return all elements from the hashmap with count greater than 1 as the duplicate elements.
Full Stack Developer Interview Questions and Answers for Freshers
Q3. Tower of Hanoi Problem Statement
You have three rods numbered from 1 to 3, and 'N' disks initially stacked on the first rod in increasing order of their sizes (largest disk at the bottom). Your task is to move ...read more
Tower of Hanoi problem involves moving 'N' disks from one rod to another following specific rules in less than 2^N moves.
Implement a recursive function to move disks from one rod to another while following the rules.
Use the concept of recursion and backtracking to solve the Tower of Hanoi problem efficiently.
Maintain a count of moves and track the movement of disks in a 2-D array/list.
Ensure that larger disks are not placed on top of smaller disks during the movement.
The solu...read more
Q4. Maximum Difference Problem Statement
Given an array ARR
of N
elements, your task is to find the maximum difference between any two elements in ARR
.
If the maximum difference is even, print EVEN; if it is odd, p...read more
Find the maximum difference between any two elements in an array and determine if it is even or odd.
Iterate through the array to find the maximum and minimum elements
Calculate the difference between the maximum and minimum elements
Check if the difference is even or odd and return the result
Q5. LCA of Binary Tree Problem Statement
You are given a binary tree consisting of distinct integers and two nodes, X
and Y
. Your task is to find and return the Lowest Common Ancestor (LCA) of these two nodes.
The ...read more
Find the Lowest Common Ancestor of two nodes in a binary tree.
Traverse the binary tree to find the paths from the root to nodes X and Y.
Compare the paths to find the last common node, which is the Lowest Common Ancestor.
Implement a recursive function to find the LCA efficiently.
Handle edge cases such as when X or Y is the root node or when X or Y is not present in the tree.
Q6. Count Set Bits Problem Statement
Given a positive integer N
, compute the total number of '1's in the binary representation of all numbers from 1 to N. Return this count modulo 1e9+7 because the result can be ve...read more
Count the total number of set bits in the binary representation of numbers from 1 to N modulo 1e9+7.
Iterate through numbers from 1 to N and count the set bits in their binary representation
Use bitwise operations to count the set bits efficiently
Return the count modulo 1e9+7 for each test case
Share interview questions and help millions of jobseekers 🌟
Q7. Most Frequent Non-Banned Word Problem Statement
Given a paragraph consisting of letters in both lowercase and uppercase, spaces, and punctuation, along with a list of banned words, your task is to find the most...read more
Find the most frequent word in a paragraph that is not in a list of banned words.
Split the paragraph into words and convert them to uppercase for case-insensitivity.
Count the frequency of each word, excluding banned words.
Return the word with the highest frequency in uppercase.
Q8. Excel Sheet Column Number Problem Statement
You are provided with a string STR
representing a column title in an Excel Sheet. Your task is to determine the corresponding column number.
Example:
A typical exampl...read more
Convert Excel sheet column title to corresponding column number.
Iterate through the characters in the string from right to left, starting with a result of 0.
For each character, calculate its value by subtracting 'A' and adding 1, then multiply by 26 raised to the power of its position from the right.
Add up all the calculated values to get the final column number.
Example: For input 'AB', A=1, B=2, so result = (1 * 26^1) + (2 * 26^0) = 28.
Full Stack Developer Jobs
Q9. Distinct Strings With Odd and Even Swapping Allowed Problem Statement
You are provided with an array of strings, and your objective is to determine the number of unique strings within it.
A string is deemed uni...read more
Determine the number of unique strings in an array by applying swapping operations on odd and even indices.
Iterate through each string in the array and check if it can be transformed into another string by swapping characters at odd and even indices.
Keep track of unique strings by comparing them with all other strings in the array.
Return the count of unique strings found in the array.
Q10. Reach the Destination Problem Statement
You are given a source point (sx, sy) and a destination point (dx, dy). Determine if it is possible to reach the destination point using only the following valid moves:
- ...read more
Determine if it is possible to reach the destination point from the source point using specified moves.
Use depth-first search (DFS) to explore all possible paths from source to destination.
Keep track of visited points to avoid infinite loops.
Check if the destination point is reachable by following the valid moves.
Return true if destination is reachable, false otherwise.
Q11. Matrix Rank Calculation
Given a matrix ARR
of dimensions N * M
, your task is to determine the rank of the matrix ARR
.
Explanation:
The rank of a matrix is defined as:
(a) The maximum number of linearly independ...read more
Calculate the rank of a matrix based on linearly independent column or row vectors.
Determine the number of linearly independent column vectors or row vectors in the matrix.
Use Gaussian elimination or row reduction to simplify the matrix and find the rank.
The rank of a matrix is the maximum number of linearly independent vectors it contains.
Q12. Find All Pairs Adding Up to Target
Given an array of integers ARR
of length N
and an integer Target
, your task is to return all pairs of elements such that they add up to the Target
.
Input:
The first line conta...read more
Find all pairs of elements in an array that add up to a given target.
Iterate through the array and store each element in a hashmap along with its index.
For each element, check if the target minus the element exists in the hashmap.
If found, print the pair of elements. If not found, print (-1, -1).
Q13. Find a Node in Linked List
Given a singly linked list of integers, your task is to implement a function that returns the index/position of an integer value 'N' if it exists in the linked list. Return -1 if the ...read more
Implement a function to find the index of a given integer in a singly linked list.
Traverse the linked list while keeping track of the index of each element.
Compare each element with the target integer 'N'.
Return the index if the element is found, otherwise return -1.
Handle cases where the target integer is not found in the linked list.
Q14. Minimum Operations Problem Statement
You are given an array 'ARR'
of size 'N'
consisting of positive integers. Your task is to determine the minimum number of operations required to make all elements in the arr...read more
Minimum number of operations to make all elements in an array equal by performing addition, subtraction, multiplication, or division.
Iterate through the array to find the maximum and minimum elements.
Calculate the difference between the maximum and minimum elements.
The minimum number of operations needed is the difference between the maximum and minimum elements.
Q15. Alternating Largest Problem Statement
Given a list of numbers, rearrange them such that every second element is greater than its adjacent elements. Implement a function to achieve this rearrangement.
Input:
The...read more
Rearrange a list of numbers such that every second element is greater than its adjacent elements.
Iterate through the array and swap elements if needed to satisfy the condition
Keep track of the current and next elements to compare and swap
Ensure that the swapped elements maintain the desired order
Q16. Factorial Calculation Problem Statement
Develop a program to compute the factorial of a given integer 'n'.
The factorial of a non-negative integer 'n', denoted as n!
, is the product of all positive integers les...read more
Program to compute factorial of a given integer 'n', with error handling for negative values.
Create a function to calculate factorial using a loop or recursion
Check if input is negative, return 'Error' if true
Handle edge cases like 0 and 1 separately
Return the calculated factorial value
Q17. Reverse Integer Problem Statement
Given a 32-bit signed integer N
, your task is to return the reversed integer. If reversing the integer causes overflow, return -1
.
Input:
The first line contains an integer 'T'...read more
The task is to reverse a 32-bit signed integer and handle overflow cases.
Create a function that takes a 32-bit signed integer as input
Reverse the integer while handling overflow cases
Return the reversed integer or -1 if overflow occurs
Q18. Add Two Numbers as Linked Lists
You are given two singly linked lists, where each list represents a positive number without any leading zeros.
Your task is to add these two numbers and return the sum as a linke...read more
Add two numbers represented as linked lists and return the sum as a linked list.
Traverse both linked lists simultaneously while keeping track of carry from previous sum
Create a new linked list to store the sum of the two numbers
Handle cases where one linked list is longer than the other by padding with zeros
Update the current node with the sum of corresponding nodes from both lists and carry
Q19. Maximum Distance Problem Statement
Given an integer array 'A' of size N, your task is to find the maximum value of j - i, with the restriction that A[i] <= A[j], where 'i' and 'j' are indices of the array.
Inpu...read more
Find the maximum distance between two elements in an array where the element at the first index is less than or equal to the element at the second index.
Iterate through the array and keep track of the minimum element encountered so far along with its index.
Calculate the maximum distance by subtracting the current index from the index of the minimum element.
Update the maximum distance if a greater distance is found while iterating.
Return the maximum distance calculated.
Q20. Count Substrings with K Distinct Characters
Given a lowercase string 'STR' and an integer K, the task is to count all possible substrings that consist of exactly K distinct characters. These substrings are not ...read more
Count substrings with exactly K distinct characters in a given lowercase string.
Iterate through all substrings of length K and count distinct characters.
Use a set to keep track of distinct characters in each substring.
Increment count if number of distinct characters equals K.
Q21. Find Indices for Local Minima and Maxima
Given an integer array arr
of size N
, your task is to determine all indices of local minima and local maxima within the array. Return these indices in a 2-D list, where ...read more
The task is to find and return the indices of local minima and local maxima in the given array.
Iterate through the array and compare each element with its neighbors to determine if it is a local minima or maxima.
Consider corner elements separately by comparing them with only one neighbor.
Store the indices of local minima and maxima in separate lists.
If there are no local minima or maxima, return -1 as the only row element in the 2-D list.
Q22. 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
The task is to find the number of distinct ways to climb from the 0th step to the Nth step, where each time you can climb either one step or two steps.
Use dynamic programming to solve this problem
Create an array to store the number of ways to reach each step
Initialize the first two elements of the array as 1 and 2
For each subsequent step, the number of ways to reach that step is the sum of the number of ways to reach the previous two steps
Return the number of ways to reach th...read more
Q23. Sub Sort Problem Statement
You are given an integer array ARR
. Determine the length of the shortest contiguous subarray which, when sorted in ascending order, results in the entire array being sorted in ascendi...read more
Determine the length of the shortest contiguous subarray that needs to be sorted to make the entire array sorted in ascending order.
Iterate from left to right to find the first element out of order.
Iterate from right to left to find the last element out of order.
Calculate the length of the subarray between the two out of order elements.
Array Sum Calculation
Calculate the sum of all elements in an array of length N
.
Input:
Line 1: An integer N indicating the size of the array.
Line 2: N integers, the elements of the array, separated by spaces.
Calculate the sum of all elements in an array of length N.
Read the size of the array N and then read N integers as elements of the array.
Iterate through the array and add each element to a running total to calculate the sum.
Return the final sum as the output.
Q25. Make Array Elements Equal Problem Statement
Given an integer array, your objective is to change all elements to the same value, minimizing the cost. The cost of changing an element from x
to y
is defined as |x ...read more
Find the minimum cost to make all elements of an array equal by changing them to the same value.
Calculate the median of the array and find the sum of absolute differences between each element and the median.
Sort the array and find the median element, then calculate the sum of absolute differences between each element and the median.
If the array has an even number of elements, consider the average of the two middle elements as the median.
Q26. 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
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.
Q27. Rotational Equivalence of Strings Problem Statement
Given two strings 'P' and 'Q' of equal length, determine if string 'P' can be transformed into string 'Q' by cyclically rotating it to the right any number of...read more
The task is to check if one string can be converted into another string by cyclically rotating it to the right any number of times.
Check if the lengths of the two strings are equal. If not, return 0.
Concatenate the first string with itself and check if the second string is a substring of the concatenated string.
If the second string is a substring, return 1. Otherwise, return 0.
Q28. what steps do you take to ensure accurate estimates the project?
To ensure accurate project estimates, I follow a structured approach that includes analyzing requirements, breaking down tasks, and considering potential risks.
Analyze project requirements thoroughly
Break down tasks into smaller, manageable chunks
Consider potential risks and challenges
Use historical data to inform estimates
Collaborate with team members to validate estimates
Q29. Count Inversions Problem Statement
Given an integer array ARR
of size N
, your task is to find the total number of inversions that exist in the array.
An inversion is defined for a pair of integers in the array ...read more
Count the total number of inversions in an integer array.
Iterate through the array and for each pair of elements, check if the inversion condition is met.
Use a nested loop to compare each pair of elements efficiently.
Keep a count of the inversions found and return the total count at the end.
Q30. Ceil Value from BST Problem Statement
Given a Binary Search Tree (BST) and an integer, write a function to return the ceil value of a particular key in the BST.
The ceil of an integer is defined as the smallest...read more
Ceil value of a key in a Binary Search Tree (BST) is the smallest integer greater than or equal to the given number.
Traverse the BST to find the closest integer greater than or equal to the given key.
Compare the key with the current node value and update the ceil value accordingly.
Recursively traverse left or right subtree based on the key value to find the ceil value.
Return the ceil value once found for each test case.
Q31. Collect Maximum Coins from Matrix
You are provided with a matrix consisting of 'M' rows and 'N' columns. Each cell in this matrix either contains a coin or is empty.
Your task is to collect the maximum number o...read more
Given a matrix with coins and empty cells, collect maximum coins from boundary cells and adjacent cells.
Iterate through the boundary cells and collect coins from them and their adjacent cells
Keep track of visited cells to avoid collecting the same coin multiple times
Use depth-first search or breadth-first search to explore adjacent cells
Q32. LRU Cache Design Question
Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:
1. get(key)
- Return the value of the key if it exists in the cache; otherwise, re...read more
Design a Least Recently Used (LRU) cache data structure that supports get and put operations with a given capacity.
Implement a doubly linked list to keep track of the order of keys based on their recent usage.
Use a hashmap to store key-value pairs for quick access and updates.
When capacity is reached, evict the least recently used item before inserting a new item.
Update the position of a key in the linked list whenever it is accessed or updated.
Q33. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an integer array containing only 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of 0s, 1s, and 2s while traversing the array.
Swap elements based on the values encountered to sort the array in-place.
Time complexity should be O(N) to solve the problem efficiently.
Q34. 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
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 the denominations and update the array based on the current denomination.
Return the value at the last cell of the array as the final result.
Q35. Maximum Consecutive Ones Problem Statement
Given a binary array 'ARR' of size 'N', your task is to determine the maximum length of a sequence consisting solely of 1’s that can be obtained by converting at most ...read more
Find the maximum length of a sequence of 1's by converting at most K zeroes into ones in a binary array.
Iterate through the array and keep track of the current window of 1's and zeroes.
Use a sliding window approach to find the maximum length of the sequence.
Update the window by flipping zeroes to ones within the limit of K flips.
Return the maximum length of the sequence obtained.
Q36. N Queens Problem
Given an integer N
, find all possible placements of N
queens on an N x N
chessboard such that no two queens threaten each other.
Explanation:
A queen can attack another queen if they are in the...read more
The N Queens Problem involves finding all possible placements of N queens on an N x N chessboard where no two queens threaten each other.
Use backtracking algorithm to explore all possible configurations.
Keep track of rows, columns, and diagonals to ensure queens do not threaten each other.
Generate valid configurations recursively and backtrack when a solution is not possible.
Q37. Number of Islands II Problem Statement
You have a 2D grid of dimensions 'N' rows by 'M' columns, initially filled with water. You are given 'Q' queries, where each query contains two integers 'X' and 'Y'. Durin...read more
The task is to determine the number of islands present on a 2D grid after each query of converting water to land.
Create a function that takes the grid dimensions, number of queries, and query coordinates as input.
For each query, convert the water at the given coordinates to land and then count the number of islands on the grid.
Use depth-first search (DFS) or breadth-first search (BFS) to identify connected land cells forming islands.
Return the number of islands after each que...read more
Q38. Cousin Nodes in a Binary Tree
Determine if two nodes in a binary tree are cousins. Nodes are considered cousins if they are at the same level and have different parents.
Explanation:
In a binary tree, each node...read more
Determine if two nodes in a binary tree are cousins based on level and parent nodes.
Traverse the binary tree to find the levels and parents of the given nodes.
Check if the nodes are at the same level and have different parents to determine if they are cousins.
Return 'YES' if the nodes are cousins, 'NO' otherwise.
Example: For input '1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1' and nodes 4 7, output is 'YES'.
Q39. Friends Pairing Problem
The task is to determine the total number of ways to pair up 'N' friends or leave some of them single, following these rules:
- Each friend can either pair with one other friend or stay s...read more
The task is to determine the total number of ways to pair up 'N' friends or leave some of them single.
Use dynamic programming to solve the problem efficiently.
Consider the base cases when N is 1, 2, and 3 to derive the general formula.
The result should be computed modulo 10^9 + 7 to handle large outputs.
Q40. Next Greater Element Problem Statement
Given a list of integers of size N
, your task is to determine the Next Greater Element (NGE) for every element. The Next Greater Element for an element X
is the first elem...read more
The task is to find the Next Greater Element for each element in a list of integers.
Iterate through the list of integers from right to left
Use a stack to keep track of elements whose NGE is yet to be found
Pop elements from the stack until a greater element is found or the stack is empty
Assign the NGE as the top element of the stack or -1 if the stack is empty
Q41. Minimum Jumps Problem Statement
Bob and his wife are in the famous 'Arcade' mall in the city of Berland. This mall has a unique way of moving between shops using trampolines. Each shop is laid out in a straight...read more
This question asks for the minimum number of trampoline jumps a person needs to make in order to reach the last shop in a mall.
The shops in the mall are laid out in a straight line and each shop has a constant value representing the maximum distance it can be jumped to.
The person starts at shop 0 and wants to reach the last shop, shop N-1.
If it is impossible to reach the last shop, the function should return -1.
The function should take the number of test cases, the number of ...read more
Q42. Topological Sort Problem Statement
Given a Directed Acyclic Graph (DAG) consisting of V
vertices and E
edges, your task is to find any topological sorting of this DAG. You need to return an array of size V
repr...read more
Topological sort of a Directed Acyclic Graph (DAG) is finding an ordering of vertices where for every directed edge u -> v, u comes before v.
Use Depth First Search (DFS) to find the topological ordering of vertices in a DAG.
Start by visiting a vertex and recursively visit its neighbors, adding the vertex to the result after visiting all neighbors.
Maintain a visited array to keep track of visited vertices and a stack to store the topological ordering.
Once all vertices are visi...read more
Q43. Anagram Pairs Verification Problem
Your task is to determine if two given strings are anagrams of each other. Two strings are considered anagrams if you can rearrange the letters of one string to form the other...read more
Determine if two strings are anagrams of each other by checking if they contain the same characters.
Create character frequency maps for both strings
Compare the frequency of characters in both maps to check if they are anagrams
Return True if the strings are anagrams, False otherwise
Q44. Find the Third Greatest Element
Given an array 'ARR' of 'N' distinct integers, determine the third largest element in the array.
Input:
The first line contains a single integer 'T' representing the number of te...read more
Find the third largest element in an array of distinct integers.
Sort the array in descending order and return the element at index 2.
Handle cases where the array has less than 3 elements separately.
Consider edge cases like negative numbers and duplicates.
Q45. Minimum Characters to Make a String Palindrome
Given a string STR
of length N
, determine the minimum number of characters to be added to the front of the string to make it a palindrome.
Input:
The first line co...read more
The task is to find the minimum number of characters needed to be added to the front of a string to make it a palindrome.
Iterate through the string from both ends and count the number of characters that need to be added to make it a palindrome.
Use two pointers approach to compare characters from start and end of the string.
Keep track of the count of characters needed to be added to form a palindrome.
Q46. Odd Even Levels in Binary Tree
Given a binary tree, the task is to compute the modulus of the difference between the sum of nodes at odd levels and the sum of nodes at even levels.
Input:
The first line contain...read more
The task is to compute the modulus of the difference between the sum of nodes at odd levels and the sum of nodes at even levels in a binary tree.
Traverse the binary tree level by level and calculate the sum of nodes at odd and even levels separately.
Find the absolute difference between the sums and return the modulus of this difference.
Handle null nodes by skipping them during the sum calculation.
Q47. Optimize Memory Usage Problem Statement
Alex wants to maximize the use of 'K' memory spaces on his computer. He has 'N' different document downloads, each with unique memory usage, and 'M' computer games, each ...read more
Maximize memory usage by pairing downloads and games within memory limit 'K'.
Sort the downloads and games in descending order.
Iterate through the downloads and games to find the pairs within memory limit 'K'.
Return the pairs that maximize memory usage.
Q48. Sort Array of Strings Problem Statement
Given an array of strings ARRSTR[]
of size N
, and a character C
, your task is to sort the ARRSTR[]
array according to a new alphabetical order that starts with the given ...read more
Sort an array of strings based on a new alphabetical order starting with a given character.
Iterate through the array of strings and compare each string based on the new alphabetical order starting with the given character.
Implement a custom sorting function that considers the new alphabetical order.
Return the sorted array of strings.
Q49. Merge Sort Problem Statement
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Explanation:
The Merge Sort algorit...read more
Implement Merge Sort algorithm to sort a sequence of numbers in non-descending order.
Understand the Merge Sort algorithm which involves dividing the array into two halves, sorting each half, and then merging them back together.
Recursively apply the Merge Sort algorithm until the size of each array is 1.
Merge the sorted halves to produce the final sorted array.
Ensure to handle the input constraints such as the number of test cases, elements in the array, and the range of eleme...read more
Q50. Check Permutation Problem Statement
Determine if two given strings, 'str1'
and 'str2'
, are permutations of each other.
Explanation:
Two strings are permutations of each other if one string's characters can be r...read more
Check if two strings are permutations of each other.
Create a character frequency map for both strings and compare them.
If the frequency of characters in both maps is the same, return true.
Handle edge cases like empty strings or strings of different lengths.
Interview Questions of Similar Designations
Top Interview Questions for Full Stack Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month