Software Developer

6500+ Software Developer Interview Questions and Answers

Updated 23 Jan 2025
search-icon
Q151. Count Inversions

For a given integer array/list 'ARR' of size 'N' containing all distinct values, find the total number of 'Inversions' that may exist.

An inversion is defined for a pair of integers in the array...read more

Q152. Help Bob Out!

Bob has just turned 18 years old and has opened a Bank account. However, since he has just opened his bank account he is not very experienced about the working of banks, therefore he asks for your ...read more

Q153. Minimum Number Of Moves To Get All Keys

Some players are put inside an ‘N’ x ‘M’ matrix ‘GRID’ one by one where:

  • ‘.’ represents an empty cell.
  • ‘#’ represents a wall.
  • ‘@’ represents the starting point.
  • Lower...read more
Q154. 0 1 Knapsack

A thief is robbing a store and can carry a maximal weight of W into his knapsack. There are N items and the ith item weighs wi and is of value vi. Considering the constraints of the maximum weight t...read more

Are these interview questions helpful?
Q155. Count all sub-arrays having sum divisible by k

Given an array ‘ARR’ and an integer ‘K’, your task is to find all the count of all sub-arrays whose sum is divisible by the given integer ‘K’.

Note:
If there exists...read more
Q156. Minimum Number Of Operations

You are given an array 'ARR' of 'N' positive integers. You need to find the minimum number of operations needed to make all elements of the array equal. You can perform addition, mul...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop
Q157. Rearrange array elements.

Given an array ‘A’ having ‘N’ integers and an integer ‘m’. You need to rearrange the array elements such that after re-arrangement difference of array elements with ‘m’ should be in a s...read more

Q158. Shortest Path in a Binary Matrix

You have been given a binary matrix of size 'N' * 'M' where each element is either 0 or 1. You are also given a source and a destination cell, both of them lie within the matrix....read more

Frequently asked in,

Software Developer Jobs

Engineer II, Software Development 3-7 years
S&P Global Inc.
4.1
Gurgaon / Gurugram
Engineer III Cslt - Software Development 4-7 years
Verizon Data Services India Pvt.Ltd
4.1
Hyderabad / Secunderabad
Software Developer - C# 4-7 years
Siemens Healthcare
4.3
Bangalore / Bengaluru
Q159. Time To Burn Tree

You have been given a binary tree of 'N' unique nodes and a Start node from where the tree will start to burn. Given that the Start node will always exist in the tree, your task is to print the...read more

Q160. Coin game winner where every player has three choices

Two players 'X' and 'Y', are playing a coin game. Initially, there are 'N' coins. Each player can pick exactly 'A' coins or 'B' coins or 1 coin. A player los...read more

Q161. Count derangements

A Derangement is a permutation of ‘N’ elements, such that no element appears in its original position. For example, an instance of derangement of {0, 1, 2, 3} is {2, 3, 1, 0}, because 2 prese...read more

Q162. Day of the Week

Write a function that calculates the corresponding day of the week for any particular date in the past or future.

For example, for the date 28th August 2020 happens to be Friday. Hence the expect...read more

Q163. Intersection Of Two Arrays

You are given two arrays 'A' and 'B' of size 'N' and 'M' respectively. Both these arrays are sorted in non-decreasing order. You have to find the intersection of these two arrays.

Inte...read more

Ans.

The problem is to find the intersection of two sorted arrays.

  • Use two pointers to iterate through the arrays.

  • Compare the elements at the current pointers and move the pointers accordingly.

  • If the elements are equal, add it to the intersection array and move both pointers.

  • If the element in the first array is smaller, move the first pointer.

  • If the element in the second array is smaller, move the second pointer.

  • Repeat until one of the pointers reaches the end of its array.

  • Return t...read more

Q164. Is node present?

For a given Binary Tree of type integer and a number X, find whether a node exists in the tree with data X or not.

Input Format:
The first line of each test case contains elements of the first...read more
Q165. Kevin And His Cards

Kevin has two packs of cards. The first pack has N cards and the second one has M cards. Every card has an integer written on it. Now, you have to tell two things. First, how many different t...read more

Q166. Maximum Path Sum in the matrix

You have been given an N*M matrix filled with integer numbers, find the maximum sum that can be obtained from a path starting from any cell in the first row to any cell in the last...read more

Q167. Mike and Mobile

Mike is a little boy who loves solving math problems. One day he was playing with his mom’s mobile. The mobile keypad contains 12 buttons { 10 digits(0-9) and 2 characters(‘*’ and ‘#’) }. Mike w...read more

Q168. Minimum Cost to Buy Oranges

You are given a bag of size 'W' kg and provided with the costs of packets with different weights of oranges as a list/array with the name 'cost'. Every i-th position in the cost denot...read more

Q169. Minimum Operations

You are given an array 'ARR' of 'N' positive integers. You need to find the minimum number of operations needed to make all elements of the array equal. You can perform addition, multiplicatio...read more

Ans.

The minimum number of operations needed to make all elements of the array equal by performing addition, multiplication, subtraction, or division on any element.

  • Iterate through the array and find the maximum and minimum values

  • Calculate the difference between the maximum and minimum values

  • Check if the difference is divisible by the length of the array

  • If divisible, return the difference divided by the length

  • If not divisible, return the difference divided by the length plus one

Q170. Next Permutation

You have been given a permutation of ‘N’ integers. A sequence of ‘N’ integers is called a permutation if it contains all integers from 1 to ‘N’ exactly once. Your task is to rearrange the number...read more

Q171. Number of Longest Increasing Subsequence

Given an integer array ‘ARR’ of length ‘N’, return the number of longest increasing subsequences in it.

The longest increasing subsequence(LIS) is the longest subsequence...read more

Q172. Pair Sum in BST.

You are given a Binary Search Tree (BST) and a target value ‘K’. Your task is to check if there exist two unique elements in the given BST such that their sum is equal to the given target ‘K’.

A...read more

Ans.

The task is to check if there exist two unique elements in the given BST such that their sum is equal to the given target 'K'.

  • Traverse the BST in-order and store the elements in a sorted array

  • Use two pointers, one at the beginning and one at the end of the array

  • Check if the sum of the elements at the two pointers is equal to the target 'K'

  • If the sum is less than 'K', move the left pointer to the right

  • If the sum is greater than 'K', move the right pointer to the left

  • Repeat the...read more

Q173. Print Permutations - String

You are given an input string 'S'. Your task is to find and return all possible permutations of the input string.

Note:
1. The input string may contain the same characters, so there w...read more
Q174. Right View

You have been given a Binary Tree of integers.

Your task is to print the Right view of it.

The right view of a Binary Tree is a set of nodes visible when the tree is viewed from the Right side and th...read more

Q175. Selling Stock

You have been given stock values/prices for N number of days. Every i-th day signifies the price of a stock on that day. Your task is to find the maximum profit which you can make by buying and sel...read more

Q176. String palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters.

Palindrome
A palindrome is a word, number, phrase, or other sequences of characters which read the sam...read more
Q177. String Transformation

Given a string (STR) of length N, you have to create a new string by performing the following operation:

Take the smallest character from the first 'K' characters of STR, remove it from ST...read more

Q178. Trapping Rain Water

Given an M * N matrix, where the value at any cell denotes the height of that cell in a 2-D elevation map. You need to find the volume of water that can be trapped within it.

For a matrix = [...read more
Q179. Check if the Word is present in Sentence or not

You have been given a sentence ‘S’ in the form of a string and a word ‘W’, you need to find whether the word is present in the given sentence or not. The word must...read more

Q180. Coin Game

Wong is hungry and wants to eat tuna melt. He checks his pocket and finds that he has only a buck left. He asked Dr. Strange to lend him some money, for which Strange agrees but to get the money, Wong ...read more

Q181. Construct Binary Tree From Inorder and Preorder Traversal

You have been given the preorder and inorder traversal of a binary tree. Your task is to construct a binary tree using the given inorder and preorder tr...read more

Ans.

The task is to construct a binary tree using the given inorder and preorder traversals.

  • Use the preorder traversal to determine the root of the binary tree

  • Use the inorder traversal to determine the left and right subtrees of the root

  • Recursively construct the left and right subtrees

  • Return the root node of the constructed binary tree

Q182. Delete middle node

You have been given a singly Linked List of integers. Your task is to delete the middle node of this List.

Note:

1. If there is no middle node in the list to delete, return an empty list (i.e....read more
Ans.

The task is to delete the middle node of a singly linked list of integers.

  • If the linked list is empty or has only one node, there is no middle node to delete.

  • To delete the middle node, we need to find the middle node and update the pointers of the previous and next nodes.

  • To find the middle node in one traversal, we can use two pointers - a slow pointer and a fast pointer.

  • The slow pointer moves one node at a time, while the fast pointer moves two nodes at a time.

  • When the fast ...read more

Q183. Find The Repeating And Missing Number

You are given an array 'nums' consisting of first N positive integers. But from the N integers, one of the integers occurs twice in the array, and one of the integers is mis...read more

Q184. Idempotent Matrix

Given a N * N matrix and the task is to check matrix is idempotent matrix or not.

See the sample input.

Idempotent matrix M follows the following property :

M*M = M 
Input format :
Line 1 : Siz...read more
Q185. Maximum Sum BST

You are given a Binary Tree ‘root’. The given Binary Tree may or may not be a Binary Search Tree(BST) itself. Your task is to find the maximum sum of node values of any subtree that is a Binary S...read more

Ans.

The task is to find the maximum sum of node values of any subtree that is a Binary Search Tree(BST).

  • Traverse the binary tree in a bottom-up manner

  • For each node, check if it forms a BST and calculate the sum of its subtree

  • Keep track of the maximum sum encountered so far

  • Return the maximum sum

Q186. Minimum Fountains

There is a one-dimensional garden of length 'N'. On each of the positions from 0 to 'N', there is a fountain, and this fountain’s water can reach up to a certain range as explained further. In ...read more

Q187. Move Zeros To Left

You are given an array 'ARR' of integers. Your task is to modify the array so that all the array elements having zero values get pushed to the left and all the array elements having non-zero v...read more

Q188. Total Unique Paths

You are present at point ‘A’ which is the top-left cell of an M X N matrix, your destination is point ‘B’, which is the bottom-right cell of the same matrix. Your task is to find the total num...read more

Q189. Detect Cycle In A Directed Graph

You are given a directed graph having ‘N’ nodes. A matrix ‘EDGES’ of size M x 2 is given which represents the ‘M’ edges such that there is an edge directed from node EDGES[i][0] ...read more

Q190. First Missing Positive

You are given an array 'ARR' of integers of length N. Your task is to find the first missing positive integer in linear time and constant space. In other words, find the lowest positive in...read more

Q191. Fruits and Baskets

There are ‘n’ fruit trees that are planted along a road. The trees are numbered from 0 to n-1. The type of fruit each tree bears is represented by an uppercase character of the English alphabe...read more

Ans.

The problem is to find the maximum number of fruits the Ninja can put in both baskets after satisfying given conditions.

  • The Ninja can start at any tree and end at any tree, but cannot skip a tree.

  • He can pick one fruit from each tree until he cannot, i.e., when he has to pick a fruit of the third type.

  • The restriction is that each basket can have only one type of fruit.

  • We need to find the maximum number of fruits that can be put in both baskets.

Q192. Last Stone Weight

We have a collection of 'N' stones, each stone has a positive integer weight.

On each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights 'x' and 'y...read more

Ans.

This question is about finding the weight of the last stone after repeatedly smashing the two heaviest stones together.

  • Sort the array of stone weights in descending order.

  • Repeatedly smash the two heaviest stones together until there is at most 1 stone left.

  • If there is 1 stone left, return its weight. Otherwise, return 0.

Q193. Maximum Sum Rectangle

You are given a matrix ‘ARR’ with ‘N’ rows and ‘M’ columns. Your task is to find the maximum sum rectangle in the matrix.

Maximum sum rectangle is a rectangle with the maximum value for the...read more

Q194. Meeting

Ninja is organizing a meeting in an office that starts at a time ‘0’ and will end at a time ‘LAST’. There are ‘N’ presentations that are going to take place in that meeting whose start and end times are ...read more

Q195. Partition Equal Subset Sum

You are given an array 'ARR' of 'N' positive integers. Your task is to find if we can partition the given array into two subsets such that the sum of elements in both subsets is equal....read more

Q196. Quick Sort

You are given an array of integers. You need to sort the array in ascending order using quick sort.

Quick sort is a divide and conquer algorithm in which we choose a pivot point and partition the arr...read more

Q197. Search In Rotated Sorted Array

You have been given a sorted array/list ARR consisting of ‘N’ elements. You are also given an integer ‘K’.

Now the array is rotated at some pivot point unknown to you. For example,...read more

Q198. Sort An Array of 0s, 1s and 2s

You have been given an array/list ARR consisting of ‘N’ elements. Each element in the array is either 0, 1 or 2.

Now, your task is to sort this array/list in increasing order. For ...read more

Q199. Spiral Matrix

You are given a 2-D array 'MATRIX' of dimensions N x M, of integers. You need to return the spiral path of the matrix.

Example Of Spiral Path:

Spiral path of a matrix

Input Format:
The first line contains an integer 'T' ...read more

Q200. A ball is left from a height of 10 meters. After bouncing first time it looses 10% of its previous height the next time it bounces. Write a code to calculate the number of bounces the ball goes through until it...

read more
Ans.

Code to calculate number of bounces a ball goes through until it comes to rest.

  • Use a loop to simulate the bounces until the ball stops bouncing

  • Calculate the height of each bounce using the given formula

  • Keep track of the number of bounces in a counter variable

Previous
1
2
3
4
5
6
7
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.4k Interviews
3.9
 • 8.1k Interviews
3.7
 • 7.6k Interviews
3.7
 • 5.6k Interviews
3.8
 • 5.6k Interviews
4.1
 • 5k Interviews
3.8
 • 4.8k Interviews
3.4
 • 1.3k Interviews
3.8
 • 529 Interviews
4.3
 • 511 Interviews
View all

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

Software Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter