Software Developer

8000+ Software Developer Interview Questions and Answers

Updated 6 Jul 2025
search-icon

Asked in SAP

2d ago

Q. Multilevel Inheritance Implementation

Create a series of classes to demonstrate multilevel inheritance.

Explanation:

Create three classes to illustrate multilevel inheritance.

  • GrandFather: This class should ha...read more
Ans.

Demonstrate multilevel inheritance with classes GrandFather, Father, and Son with specific attributes and methods.

  • Create a class GrandFather with a parameterized constructor and attribute grandFatherName.

  • Create a class Father inheriting from GrandFather with an additional attribute fatherName.

  • Create a class Son inheriting from Father with an additional attribute sonName and a method printName to display all names in a specific format.

  • Ensure constructors initialize attributes ...read more

Asked in Info Edge

4d ago

Q. Rearrange Array Elements Problem Statement

Given an array A containing 'N' integers and an integer m, rearrange the elements of the array such that the differences between the array elements and m are sorted in...read more

Ans.

Rearrange array elements based on their differences from a given integer.

  • Calculate the differences between each element and the given integer.

  • Sort the elements based on their differences while maintaining the original order for elements with the same difference.

  • Implement a function to rearrange the array elements as per the given criteria.

Asked in Amazon

1w ago

Q. Search in a Row-wise and Column-wise Sorted Matrix Problem Statement

You are given an N * N matrix of integers where each row and each column is sorted in increasing order. Your task is to find the position of ...read more

Ans.

This question asks to find the position of a target integer in a row-wise and column-wise sorted matrix.

  • Iterate through each row and column of the matrix

  • Compare the target integer with the current element

  • If the target integer is found, return the position as {i, j}

  • If the target integer is not found, return {-1, -1}

Asked in Barclays

1w ago

Q. Shopping Spree Problem Statement

Preeti plans to shop for her father's birthday at a store with unlimited quantities of N different items. She has a budget that allows her to buy a maximum of K items. Help Pree...read more

Ans.

Calculate the number of ways Preeti can purchase items within budget, with at least one item quantity differing.

  • Use dynamic programming to calculate the number of ways to purchase items within budget.

  • Consider different scenarios where Preeti buys different quantities of each item.

  • Return the result modulo 10^9 + 7 to handle large answers.

Are these interview questions helpful?
2d ago

Q. Split Binary String Problem Statement

Chintu has a long binary string str. A binary string is a string that contains only 0 and 1. He considers a string to be 'beautiful' if and only if the number of 0's and 1'...read more

Ans.

Find the maximum number of beautiful substrings that a binary string can be split into.

  • Count the number of 0's and 1's in the string.

  • Iterate through the string and split it whenever the count of 0's and 1's becomes equal.

  • Return the maximum number of beautiful substrings that can be formed.

Asked in Adobe

2w ago

Q. Tiling Problem Statement

Given a board with 2 rows and N columns, and an infinite supply of 2x1 tiles, determine the number of distinct ways to completely cover the board using these tiles.

You can place each t...read more

Ans.

The problem involves finding the number of ways to tile a 2xN board using 2x1 tiles.

  • Use dynamic programming to solve this problem efficiently.

  • Define a recursive function to calculate the number of ways to tile the board.

  • Consider both horizontal and vertical placements of tiles.

  • Implement the function to handle large values of N using modulo arithmetic.

  • Example: For N = 4, the number of ways to tile the board is 5.

Software Developer Jobs

Siemens Healthcare logo
Software Developer (C# )- Cybersecurity & Third-Party Software 3-7 years
Siemens Healthcare
4.2
Bangalore / Bengaluru
Siemens Healthcare logo
Software Developer - (C# ,Windows Security) 3-7 years
Siemens Healthcare
4.2
Bangalore / Bengaluru
IBM India Pvt. Limited logo
Software Developer (Go, Cloud, Kubernetes) 7-12 years
IBM India Pvt. Limited
4.0
₹ 5 L/yr - ₹ 65 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru

Asked in Google

4d ago

Q. An image (square image) can be stored as a tree: A node is white if the image is white, is black if the image is black, and is mixed if it contains both. White and black nodes are leaves, whereas a mixed node w...

read more
Ans.

Find the intersection of two square images represented as trees based on color rules.

  • A white node (W) intersects with another white node (W) results in W.

  • A black node (B) intersects with another black node (B) results in B.

  • A white node (W) intersects with a black node (B) results in W.

  • A mixed node (M) will have 4 children representing the intersection of its quadrants.

Asked in SAP

2w ago

Q. BFS Traversal in a Graph

Given an undirected and disconnected graph G(V, E) where V vertices are numbered from 0 to V-1, and E represents edges, your task is to output the BFS traversal starting from the 0th ve...read more

Ans.

BFS traversal of an undirected and disconnected graph starting from vertex 0.

  • Implement BFS algorithm to traverse the graph starting from vertex 0.

  • Use a queue to keep track of visited nodes and their neighbors.

  • Ensure the traversal starts from vertex 0 and follows the BFS order.

  • Output the BFS traversal sequence for each test case in a separate line.

  • Handle disconnected components by checking for unvisited nodes.

  • Consider the constraints for the number of vertices and edges in the...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q. Binary Tree Right View Problem Statement

Given a binary tree of integers, your task is to print the right view of it. The right view represents a set of nodes visible when the tree is viewed from the right side...read more

Ans.

The task is to print the right view of a binary tree, representing nodes visible from the right side in top-to-bottom order.

  • Traverse the tree level by level and keep track of the rightmost node at each level

  • Print the rightmost node of each level to get the right view of the tree

  • Use a queue for level order traversal and a map to store the rightmost nodes

Asked in Deloitte

1w ago

Q. Bursting Balloons Problem

Given an array ARR of size N, where each element represents the height of a balloon. The task is to destroy all balloons by shooting arrows from left to right. When an arrow hits a bal...read more

Ans.

Find the minimum number of arrows needed to burst all balloons by shooting arrows from left to right.

  • Sort the array in non-decreasing order to make it easier to calculate the minimum number of arrows needed.

  • Iterate through the sorted array and count the number of times the height decreases compared to the previous balloon.

  • The count of decreases + 1 will give the minimum number of arrows needed to burst all balloons.

  • Example: For input N = 5, ARR = [2, 3, 4, 5, 1], the minimum ...read more

Asked in Tata 1mg

1w ago

Q. Cache Operations Problem

You are provided with a cache that can hold a maximum of 'N' elements. Initially, this cache is empty. There are two main operations you can perform on this cache:

Explanation:

  • Operati...read more
Ans.

Implement a cache with insert, update, and retrieve operations, returning results of retrieve operations in order.

  • Create a cache data structure with specified size 'N'.

  • Implement insert and update operations based on the given criteria.

  • For retrieve operation, return the value associated with the 'U_ID' if present, else return -1.

  • Handle cases where the cache is full and least frequently used items need to be removed.

  • Return the results of all retrieve operations in the order the...read more

Asked in Amazon

5d ago

Q. 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

Ans.

The task is to count the total number of '1' in the binary representation of all numbers from 1 to N.

  • Convert each number from 1 to N into its binary representation

  • Count the number of '1' bits in each binary representation

  • Sum up the counts of '1' bits for all numbers

  • Return the sum modulo 1e9+7

Asked in Arcesium

1w ago

Q. Count Subarrays with Sum Divisible by K

Given an array ARR and an integer K, your task is to count all subarrays whose sum is divisible by the given integer K.

Input:

The first line of input contains an integer...read more
Ans.

Count subarrays with sum divisible by K in an array.

  • Iterate through the array and keep track of the running sum modulo K.

  • Use a hashmap to store the frequency of remainders.

  • For each prefix sum, check how many previous prefix sums have the same remainder.

  • Return the total count of subarrays with sum divisible by K.

1w ago

Q. Given an infinite sequence of continuous natural numbers 1, 2, 3, 4, 5, 6, ..., initially you delete every 2nd element, so the sequence will be 1, 3, 5, 7, 9, 11, 13, .... Now, in the resultant sequence, you de...

read more
Ans.

Program to check if a given number is a lucky number or not.

  • Create a function that takes an integer n as input

  • Initialize a variable count to 2

  • Loop through the sequence and delete every count-th element

  • Repeat the above step until the end of the sequence

  • If n is present in the final sequence, return true, else return false

Asked in Bottomline

2w ago

Q. Help Bob Out! - Validating IFSC Code

Bob has just turned 18 and opened a bank account. Being inexperienced with banking, Bob needs your help to validate whether an IFSC code provided by his bank is valid.

The v...read more

Ans.

Validate IFSC code based on given rules and return True or False for each test case.

  • Check if the code is 11 characters long.

  • Verify the first four characters are uppercase alphabets.

  • Ensure the fifth character is '0'.

  • Validate that the last six characters are alphanumeric.

Asked in Salesforce

1w ago

Q. Longest Happy String Problem Statement

Given three non-negative integers X, Y, and Z, determine the longest happy string. A happy string is defined as a string that contains only the letters 'a', 'b', and 'c' w...read more

Ans.

The problem involves constructing the longest happy string with given constraints on the frequency of 'a', 'b', and 'c'.

  • Iterate through the characters 'a', 'b', 'c' in decreasing order of their frequencies

  • Append the character with the highest frequency that does not create a substring of 3 same characters

  • Repeat until all characters are used up or the string reaches the desired length

2w ago

Q. Maximum Non-Adjacent Subsequence Sum

Given an array of integers, determine the maximum sum of a subsequence without choosing adjacent elements in the original array.

Input:

The first line consists of an integer...read more
Ans.

Find the maximum sum of a subsequence without choosing adjacent elements in an array.

  • Use dynamic programming to keep track of the maximum sum at each index, considering whether to include or exclude the current element.

  • At each index, the maximum sum can be 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 accordingly.

  • Example: For input [3, 2, 7, 10], the maximum non-a...read more

Asked in SAP

1w ago

Q. Next Permutation Problem Statement

You are given a permutation of 'N' integers. A sequence of 'N' integers is considered a permutation if it includes all integers from 1 to 'N' exactly once. Your task is to rea...read more

Ans.

Given a permutation of 'N' integers, rearrange the numbers to form the lexicographically next greater permutation.

  • Iterate from right to left to find the first element that is smaller than the element to its right.

  • Swap this element with the smallest element to its right that is greater than it.

  • Reverse the elements to the right of the swapped element to get the lexicographically next greater permutation.

  • If no such element is found in step 1, then the permutation is already the ...read more

Asked in Accenture

2w ago

Q. Ninja and Candies Problem

Ninja, a boy from Ninjaland, receives 1 coin every morning from his mother. He wants to purchase exactly 'N' candies. Each candy usually costs 2 coins, but it is available for 1 coin i...read more

Ans.

Calculate the earliest day on which Ninja can buy all candies with special offers.

  • Iterate through each day and check if any special offer is available for candies Ninja wants to buy

  • Keep track of the minimum day on which Ninja can buy all candies

  • Consider both regular price and sale price of candies

2w ago

Q. Pirates of different ages have a treasure of 100 gold coins. On their ship, they decide to split the coins using this scheme: The oldest pirate proposes how to share the coins, the OTHER pirates (not including...

read more
Ans.

The oldest pirate proposes to keep 98 coins for himself and give 1 coin to each of the other pirates.

  • The oldest pirate will propose to keep the majority of the coins for himself to ensure the vote passes.

  • The other pirates will vote in favor of the proposal to avoid being thrown overboard.

  • The proposed distribution will be 98 coins for the oldest pirate and 1 coin for each of the other pirates.

Asked in Paytm

6d ago

Q. Print Nodes at Distance K from a Given Node

Given an arbitrary binary tree, a node of the tree, and an integer 'K', find all nodes that are at a distance K from the specified node, and return a list of these no...read more

Ans.

Given a binary tree, a target node, and an integer K, find all nodes at distance K from the target node.

  • Traverse the binary tree to find the target node.

  • Use BFS to traverse the tree from the target node to nodes at distance K.

  • Keep track of the distance while traversing the tree.

  • Return the values of nodes at distance K in any order.

Asked in Swiggy

4d ago

Q. Shuffle Two Strings Problem Statement

You are provided with three strings A, B, and C. The task is to determine if C is formed by interleaving A and B. C is considered an interleaving of A and B if:

  • The length...read more
Ans.

Check if a string is formed by interleaving two other strings.

  • Iterate through characters of A, B, and C simultaneously to check if C is formed by interleaving A and B.

  • Use dynamic programming to efficiently solve the problem.

  • Handle edge cases like empty strings or unequal lengths of A, B, and C.

  • Example: A = 'aab', B = 'abc', C = 'aaabbc' should return True.

Asked in Amazon

5d ago

Q. Snake and Ladder Problem Statement

Given a 'Snake and Ladder' board with N rows and N columns, where positions are numbered from 1 to (N*N) starting from the bottom left, alternating direction each row, find th...read more

Ans.

Find the minimum number of dice throws required to reach the last cell on a 'Snake and Ladder' board.

  • Start from the bottom left cell and move according to dice outcomes (1-6).

  • Utilize snakes and ladders to reach the last cell faster.

  • Keep track of the minimum number of throws required to reach the last cell.

  • If unreachable, return -1 as output.

Asked in Amazon

1w ago

Q. 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

Ans.

The goal is to determine the maximum profit that can be achieved by buying and selling stocks on different days.

  • Iterate through the stock prices and buy on days when the price is lower than the next day, and sell on days when the price is higher than the next day.

  • Calculate the profit by summing up the differences between buying and selling prices.

  • Repeat the process for each test case and output the maximum profit achieved.

  • Example: For prices [7, 1, 5, 3, 6, 4], buy on day 2 a...read more

Asked in Amazon

2w ago

Q. String Transformation Problem Statement

Given a string str of length N, perform a series of operations to create a new string:

  1. Select the smallest character from the first 'K' characters of the string, remove ...read more
Ans.

The problem involves selecting the smallest character from the first 'K' characters of a string and appending it to a new string until the original string is empty.

  • Iterate through the string, selecting the smallest character from the first 'K' characters each time.

  • Remove the selected character from the original string and append it to the new string.

  • If fewer than 'K' characters remain, sort and append them in order.

  • Repeat the process until the original string is empty.

Asked in TCS

2w ago

Q. Every day, we come across different types of computer software that helps us with our tasks and increase our efficiency. From MS Windows that greets us when we switch on the system to the web browser that is us...

read more
Ans.

Software is a collection of data, programs, procedures, instructions, and documentation that perform tasks on a computer system.

  • Software is essential for computers to be useful.

  • It includes programs, libraries, and non-executable data.

  • Software and hardware work together to enable modern computing systems.

  • Examples of software include operating systems, web browsers, and games.

1w ago

Q. N-th Fibonacci Number Problem Statement

Given an integer ‘N’, your task is to find and return the N’th Fibonacci number using matrix exponentiation.

Since the answer can be very large, return the answer modulo ...read more

Ans.

The task is to find the Nth Fibonacci number using matrix exponentiation.

  • Use matrix exponentiation to efficiently calculate the Nth Fibonacci number

  • Return the answer modulo 10^9 + 7 to handle large numbers

  • Implement the function to solve the problem

  • The Fibonacci sequence starts with 1, 1, so F(1) = F(2) = 1

  • The time complexity can be improved to better than O(N) using matrix exponentiation

Asked in LTIMindtree

2w ago

Q. Problem: Count Even or Odd in Array

Tanmay and Rohit are best buddies. Tanmay gives Rohit a challenge involving an array of N natural numbers. The task is to perform and answer a series of queries on the array ...read more

Ans.

Count the number of even or odd numbers in a range of an array based on given queries.

  • Create an array to store the input numbers.

  • Iterate through the queries and update or count even/odd numbers based on the query type.

  • Output the count of even or odd numbers for each query of type 1 or 2.

Q. Remove Character from String Problem Statement

Given a string str and a character 'X', develop a function to eliminate all instances of 'X' from str and return the resulting string.

Input:

The first line contai...read more
Ans.

Develop a function to remove all instances of a given character from a string.

  • Iterate through the string character by character and exclude the specified character while constructing the new string.

  • Use a StringBuilder or similar data structure for efficient string manipulation.

  • Handle edge cases such as empty string or character not found in the input string.

  • Ensure the function runs in O(N) time complexity where N is the length of the input string.

2w ago

Q. Selection Sort Algorithm

Selection sort is a sorting technique that works by repeatedly finding the minimum element (considering ascending order) from the unsorted part and placing it at the beginning of the un...read more

Ans.

Selection Sort Algorithm sorts an array by repeatedly finding the minimum element and placing it at the beginning of the unsorted part.

  • Iterate through the array to find the minimum element and swap it with the first unsorted element.

  • Repeat this process for each element in the array until it is fully sorted.

  • Time complexity of Selection Sort is O(n^2) making it inefficient for large arrays.

Previous
3
4
5
6
7
8
9
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.7
 • 8.7k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
View all
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

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
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits