Software Developer
8000+ Software Developer Interview Questions and Answers

Asked in 24/7 Customer

Q. Reverse a Stack Using Recursion
You are given a stack of integers. Your task is to reverse the stack using recursion without using any extra space other than the internal stack space used due to recursion. You ...read more
Reverse a stack using recursion without using any extra space other than the internal stack space.
Use recursion to pop all elements from the original stack and store them in function call stack
Once the stack is empty, push the elements back in reverse order using recursion
Make use of auxiliary functions to handle the recursion process

Asked in upGrad

Q. Sort 0 and 1 Problem Statement
Given an integer array ARR
of size N
containing only integers 0 and 1, implement a function to sort this array. The solution should scan the array only once without using any addi...read more
Sort an array of 0s and 1s in linear time without using additional arrays.
Iterate through the array and maintain two pointers, one for 0s and one for 1s.
Swap elements at the two pointers based on the current element being 0 or 1.
Continue this process until the entire array is sorted in place.

Asked in Avalara Technologies

Q. Square Root (Integral) Problem Statement
Given a number N
, calculate its square root and output the integer part only.
Example:
Input:
18
Output:
4
Explanation:
The square root of 18 is approximately 4.24. The ...read more
Calculate the integer square root of a given number.
Use binary search to find the square root of the number.
Start with a range from 0 to N, and iteratively narrow down the range until you find the integer square root.
Return the integer part of the square root as the output.

Asked in TCS

Q. Strings of Numbers Problem Statement
You are given two integers 'N' and 'K'. Consider a set 'X' of all possible strings of 'N' number of digits where all strings only contain digits ranging from 0 to 'K' inclus...read more
The task is to find a string of minimal length that includes every possible string of N digits with digits ranging from 0 to K as substrings.
Generate all possible strings of N digits with digits from 0 to K
Concatenate these strings in a way that all are substrings of the final string
Return 1 if the final string contains all possible strings, else return 0

Asked in Jio

Q. Triple Sum Problem Statement
Bojack wants to gift Todd a binary tree with N
nodes for his birthday. However, the tree is too large, so he decides to select exactly three nodes such that their sum equals a given...read more
The task is to determine if it is possible to select three nodes from a binary tree such that their sum equals a given value.
Traverse the binary tree and store all the node values in an array
Use three nested loops to iterate through all possible combinations of three nodes
Check if the sum of the three nodes equals the given value
If a valid combination is found, return True
If no valid combination is found, return False

Asked in Microsoft Corporation

Q. A file or a directory can be represented as a node with properties like ID, parent ID, name, and number of children (0 for a file). The file structure is a linked list of nodes where the parent directory always...
read moreImplement a GUI to display a file structure using a linked list of nodes representing files and directories.
Each node has properties: ID, parent ID, name, and number of children.
The linked list maintains the order: parent directories appear before their children.
To display children, traverse the linked list and check for matching parent IDs.
Example: For a parent node with ID 1, find all nodes with parent ID 1 to display its children.
Use a recursive function to handle expandin...read more
Software Developer Jobs




Asked in Amazon

Q. Delete Alternate Nodes from a Singly Linked List
Given a Singly Linked List of integers, remove all the alternate nodes from the list.
Input:
The first and the only line of input will contain the elements of th...read more
Remove alternate nodes from a singly linked list of integers.
Traverse the linked list and skip every alternate node while updating the next pointers.
Make sure to handle cases where there are less than 3 nodes in the list.
Update the next pointers accordingly to remove alternate nodes.
Example: Input: 10 20 30 40 50 60 -1, Output: 10 30 50

Asked in Mobile Premier League

Q. Is the Sentence a Pangram?
Ninja is relocating to a place called NinjaGram, and for school admission, he is required to identify if a given sentence is a pangram. Your task is to assist Ninja in determining if ...read more
Yes, the sentence is a pangram if it includes every letter of the English alphabet at least once.
Check if the sentence contains all 26 letters of the English alphabet.
Convert the sentence to lowercase to simplify the checking process.
Use a set to keep track of the letters present in the sentence.
Iterate through the sentence and add each unique letter to the set.
After iterating, check if the set contains all 26 letters.
Share interview questions and help millions of jobseekers 🌟

Asked in Urban Company

Q. Meeting Rooms Allocation Problem Statement
Stark Industry is planning to organize meetings for various departments in preparation for Stark Expo. Due to limited rooms in Stark Tower, the goal is to allocate mee...read more
Determine the minimum number of conference rooms needed to schedule meetings without overlap.
Sort the meetings by start time.
Iterate through the meetings and keep track of the rooms in use.
If a meeting starts after another ends, it can reuse the same room.
If a meeting starts before another ends, a new room is needed.
Return the maximum number of rooms in use at any point.

Asked in Amazon

Q. Weighted Job Scheduling Problem Statement
You have 'N' jobs, each with a start time, end time, and profit. Your task is to identify the maximum profit that can be earned by scheduling these jobs such that no tw...read more
The Weighted Job Scheduling problem involves maximizing profit by scheduling non-overlapping jobs with start time, end time, and profit given.
Sort the jobs based on their end times in ascending order.
Initialize an array 'dp' to store the maximum profit that can be earned by scheduling jobs up to that index.
For each job, find the maximum profit by either including or excluding the current job based on non-overlapping condition.
Return the maximum profit from the 'dp' array.
Exam...read more

Asked in Amazon

Q. Car Pooling Problem Statement
You are tasked with driving a cab that moves in a straight line, only forward, and initially has 'C' empty seats available for passengers.
Given 'N' trips, each defined by three in...read more
The problem involves determining if a cab with a certain capacity can successfully pick up and drop off passengers at specified points for multiple trips.
Create a function that takes in the car's capacity, number of trips, and trip details as input
Iterate through each trip and check if the total number of passengers picked up and dropped off is within the car's capacity
Return 'True' if all trips can be successfully completed, 'False' otherwise

Asked in Amazon

Q. Dice Throws Problem Statement
You are given D
dice, each having F
faces numbered from 1 to F
. The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers e...read more
The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers equals the given 'target' sum.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the number of ways to achieve each sum with the given number of dice.
Iterate through the dice and faces to calculate the number of ways to reach each sum.
Return the result modulo 10^9 + 7.
Optimize the solution to use no more than O(S) extra space by u...read more

Asked in Dunzo

Q. Distance To Nearest 1 in a Binary Matrix Problem
Given a binary matrix MAT
containing only 0s and 1s of size N x M, find the distance of the nearest cell containing 1 for each cell in the matrix.
The distance i...read more
Given a binary matrix, find the distance of the nearest cell having 1 in the matrix for each cell.
Use BFS to traverse the matrix and find the nearest cell having 1 for each cell.
Initialize the output matrix with maximum possible distance.
If the current cell has 1, distance is 0, else update distance based on the nearest cell having 1.

Asked in Maersk

Q. Fourth Largest Element in the Array
Given an array consisting of integers, your task is to determine the fourth largest element in the array. If the array does not contain at least four distinct elements, retur...read more
Find the fourth largest element in an array, return -2147483648 if not enough distinct elements.
Sort the array in descending order
Return the fourth element if it exists, else return -2147483648

Asked in Bank of America

Q. Multiples of 2 and 3 Problem Statement
Ninja is engaged in a task involving divisors. He is given 'N' numbers, and his objective is to compute the sum of all numbers which are divisible by either 2 or 3.
Exampl...read more
Find the sum of numbers divisible by 2 or 3 from a given list of numbers.
Iterate through the list of numbers and check if each number is divisible by 2 or 3.
If a number is divisible by 2 or 3, add it to the sum.
Return the final sum as the output.

Asked in Avalon Information Systems

Q. Reverse String Word Wise Problem Statement
Your task is to reverse the given string word-wise. This means the last word in the string should appear first, the second last word should appear second, and so forth...read more
The given string needs to be reversed word wise, keeping the individual words intact.
Split the string into an array of words using a space as the delimiter.
Reverse the array of words.
Join the reversed array of words using a space as the separator to form the final reversed string.

Asked in MAQ Software

Q. 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 array of 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of the positions of 0s, 1s, and 2s in the array.
Iterate through the array and swap elements based on the values encountered.
Maintain left pointer for 0s, right pointer for 2s, and current pointer for traversal.
Example: If current element is 0, swap it with element at left pointer and increment both pointers.

Asked in Microsoft Corporation

Q. Time to Burn Tree Problem
You are given a binary tree consisting of 'N' unique nodes and a start node where the burning will commence. The task is to calculate the time in minutes required to completely burn th...read more
Calculate the time in minutes required to completely burn a binary tree starting from a given node.
Traverse the tree to find the start node and calculate the time for fire to spread to all nodes.
Use a queue to keep track of nodes to be burnt next.
Increment time for each level of nodes burnt until the entire tree is burnt.

Asked in Goldman Sachs

Q. Count Pairs with Difference K
Given an array of integers and an integer K
, determine and print the count of all pairs in the array that have an absolute difference of K
.
Input:
The first line of the input conta...read more
Count pairs in an array with a specific absolute difference.
Iterate through the array and for each element, check if the element + K or element - K exists in the array.
Use a hash set to store elements for constant time lookups.
Keep track of the count of valid pairs found.

Asked in Rupeek

Q. Hurdle Game Problem Statement
Kevin is playing a hurdle game where he must jump over hurdles to clear levels. Each level ‘i’ consists of ‘i’ hurdles (e.g., Level 6 has 6 hurdles).
Given the total number of hurd...read more
The task is to determine the number of levels cleared by Kevin based on the total number of hurdles he has jumped.
Each level 'i' has 'i' hurdles, so Kevin can only reach level 'i' if he has cleared level 'i-1'.
Count the number of levels cleared by dividing the total number of hurdles by the sum of the first 'n' natural numbers.
The formula to calculate the sum of the first 'n' natural numbers is (n * (n + 1)) / 2.

Asked in Samsung Research

Q. Batch Photography Problem
Alex has acquired a machine that can photocopy photos in batches of a minimum size 'K'. Given 'N' photos with resolutions represented in an integer array photos
, the machine produces a...read more
Minimize maximum error by splitting photos into batches of size at least 'K'.
Sort the array of resolutions in ascending order.
Iterate through the array and calculate the error for each possible batch.
Return the minimum possible maximum error found.

Asked in Optum Global Solutions

Q. Count Pairs Problem Statement
You are given an array A
of length N
consisting only of integers. Additionally, you are provided with three integers X
, Y
and SUM
. Your task is to count the number of pairs (i, j)
...read more
Count the number of pairs in an array that satisfy a given equation.
Iterate through all pairs of indices in the array and check if the equation is satisfied.
Use a hashmap to store the frequency of values that can be used to form pairs.
Optimize the solution by using two pointers approach to find pairs efficiently.

Asked in Sourcefuse Technologies

Q. Count Ways to Climb Stairs Problem
Given a staircase with a certain number of steps, you start at the 0th step, and your goal is to reach the Nth step. At every step, you have the option to move either one step...read more
Count the number of distinct ways to climb a staircase with a certain number of steps using either one or two steps at a time.
Use dynamic programming to solve this problem efficiently.
Keep track of the number of ways to reach each step by considering the number of ways to reach the previous two steps.
Return the result modulo 10^9+7 to handle large outputs.
Example: For N=4, the distinct ways to climb are {(0,1,2,3,4)}, {(0,1,2,4)}, {(0,2,3,4)}, {(0,1,3,4)}, and {(0,2,4)} total...read more

Asked in Microsoft Corporation

Q. Day of the Week Calculation
Your task is to create a function that determines the day of the week for any given date, whether in the past or the future.
Input:
The first line consists of an integer 'T', represe...read more
Create a function to determine the day of the week for any given date.
Parse the input integers to create a date object
Use a library or algorithm to calculate the day of the week for the given date
Return the corresponding day of the week as a string

Asked in PayPal

Q. Delete a Node from a Linked List
You are provided with a linked list of integers. Your task is to implement a function that deletes a node located at a specified position 'POS'.
Input:
The first line contains a...read more
Implement a function to delete a node from a linked list at a specified position.
Traverse the linked list to find the node at the specified position.
Update the pointers of the previous and next nodes to skip the node to be deleted.
Handle edge cases such as deleting the head or tail of the linked list.
Ensure to free the memory of the deleted node to avoid memory leaks.

Asked in Adobe

Q. Kevin and His Cards Problem Statement
Kevin has two packs of cards. The first pack contains N cards, and the second contains M cards. Each card has an integer written on it. Determine two results: the total num...read more
Find total distinct card types and common card types between two packs of cards.
Create a set to store distinct card types when combining both packs.
Iterate through each pack and add card types to the set.
Find the intersection of card types between the two packs to get common card types.

Asked in Oyo Rooms

Q. Maximum Sum of Non-Adjacent Elements
Given an array/list of ‘N’ integers, your task is to return the maximum sum of the subsequence where no two elements are adjacent in the given array/list.
Example:
Input:
T ...read more
Find the maximum sum of non-adjacent elements in an array.
Use dynamic programming to keep track of the maximum sum at each index, considering whether to include the current element or skip it.
At each index, the maximum sum is either the sum of the current element and the element two positions back, or the sum at the previous index.
Iterate through the array and update the maximum sum at each index accordingly.
Return the maximum sum obtained at the last index as the final resul...read more

Asked in Flipkart

Q. Median of Subarrays of Specific Size
Given an integer array ARR
of size N
and a specified subarray size M
, calculate and return the median of all subarrays of size M
starting from the left of the array.
The med...read more
Calculate and return the median of all subarrays of a specified size in an integer array.
Iterate through the array and for each subarray of size M, calculate the median.
If the size of the subarray is even, take the average of the two middle numbers as the median.
Return the list of medians for all subarrays of size M.

Asked in Josh Technology Group

Q. Non-Decreasing Array Problem Statement
Given an integer array ARR
of size N
, determine if it can be transformed into a non-decreasing array by modifying at most one element.
An array is defined as non-decreasin...read more
Determine if an array can be transformed into a non-decreasing array by modifying at most one element.
Iterate through the array and check if there are more than one decreasing elements.
If there is only one decreasing element, check if modifying it can make the array non-decreasing.
Return true if the array can be made non-decreasing by modifying at most one element, otherwise false.

Asked in JPMorgan Chase & Co.

Q. Reverse Words in a String: Problem Statement
You are given a string of length N
. Your task is to reverse the string word by word. The input may contain multiple spaces between words and may have leading or trai...read more
Reverse words in a string while handling leading, trailing, and multiple spaces.
Split the input string by spaces to get individual words
Reverse the order of the words
Join the reversed words with a single space in between
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for Software Developer Related Skills



Reviews
Interviews
Salaries
Users

