Software Developer

8000+ Software Developer Interview Questions and Answers

Updated 15 Jul 2025
search-icon

Asked in Amazon

3d ago

Q. Maximum Subarray Sum Problem Statement

Given an array of integers, determine the maximum possible sum of any contiguous subarray within the array.

Example:

Input:
array = [34, -50, 42, 14, -5, 86]
Output:
137
E...read more
Ans.

Find the maximum sum of any contiguous subarray within an array of integers.

  • Iterate through the array and keep track of the maximum sum of subarrays encountered so far.

  • At each index, decide whether to include the current element in the subarray or start a new subarray.

  • Use Kadane's algorithm to efficiently find the maximum subarray sum in O(N) time complexity.

Asked in Blackrock

2d ago

Q. Merge Two Sorted Arrays Problem Statement

Given two sorted integer arrays ARR1 and ARR2 of size M and N, respectively, merge them into ARR1 as one sorted array. Assume that ARR1 has a size of M + N to hold all ...read more

Ans.

Merge two sorted arrays into one sorted array in place.

  • Iterate from the end of both arrays and compare elements to merge in place

  • Use two pointers to keep track of the current position in each array

  • Handle cases where one array is fully merged before the other

Software Developer Interview Questions and Answers for Freshers

illustration image

Asked in Amazon

1d ago

Q. Minimum Number of Platforms Needed Problem Statement

You are given the arrival and departure times of N trains at a railway station for a particular day. Your task is to determine the minimum number of platform...read more

Ans.

Determine the minimum number of platforms needed at a railway station based on arrival and departure times of trains.

  • Sort the arrival and departure times in ascending order.

  • Use two pointers to keep track of overlapping schedules.

  • Increment the platform count when a new train arrives before the previous one departs.

  • Return the maximum platform count needed.

Asked in Cognizant

4d ago

Q. Nth Fibonacci Number Problem Statement

Calculate the Nth term in the Fibonacci sequence, where the sequence is defined as follows: F(n) = F(n-1) + F(n-2), with initial conditions F(1) = F(2) = 1.

Input:

The inp...read more
Ans.

Calculate the Nth Fibonacci number efficiently using dynamic programming.

  • Use dynamic programming to store and reuse previously calculated Fibonacci numbers.

  • Start with base cases F(1) and F(2) as 1, then calculate subsequent Fibonacci numbers.

  • Optimize the solution to avoid redundant calculations by storing intermediate results.

  • Time complexity can be reduced to O(N) using dynamic programming.

  • Example: For N = 5, the 5th Fibonacci number is 5.

Are these interview questions helpful?

Q. Form a Triangle Problem Statement

You are given an array of integers ARR with a length of N. Your task is to determine whether it's possible to construct at least one non-degenerate triangle using the values fr...read more

Ans.

Determine if it's possible to form a non-degenerate triangle using array elements as sides.

  • Check if the sum of any two sides is greater than the third side to form a triangle.

  • If any such combination exists, return 'YES'; otherwise, return 'NO'.

  • Example: For input [3, 4, 5], sum of 3 + 4 > 5, so 'YES'. For [1, 10, 12, 30], no such combination exists, so 'NO'.

Asked in Nagarro

5d ago

Q. Crazy Numbers Pattern Challenge

Ninja enjoys arranging numbers in a sequence. He plans to arrange them in 'N' rows such that:

  • The first row contains 1 number.
  • The second row contains 2 numbers.
  • The third row c...read more
Ans.

Arrange numbers in a sequence in 'N' rows with increasing order and repeating after 9.

  • Iterate through each test case and for each row, print numbers in increasing order with a loop.

  • Keep track of the current number to print and reset to 1 after reaching 9.

  • Handle formatting to align numbers correctly in each row.

  • Ensure to print the correct number of rows based on the input 'N'.

Software Developer Jobs

IBM India Pvt. Limited logo
Software Developer 5-10 years
IBM India Pvt. Limited
3.9
₹ 4 L/yr - ₹ 65 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru
IBM India Pvt. Limited logo
Software Developer - Windows App Support 5-10 years
IBM India Pvt. Limited
3.9
₹ 4 L/yr - ₹ 65 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru
IBM India Pvt. Limited logo
IBM Public Cloud CTO Software Developer 4-9 years
IBM India Pvt. Limited
3.9
₹ 3 L/yr - ₹ 60 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru

Asked in Meesho

2d ago

Q. Array Intersection Problem Statement

Given two integer arrays/ lists ARR1 and ARR2 of sizes N and M respectively, you are required to determine their intersection. An intersection is defined as the set of commo...read more

Ans.

The task is to find the intersection of two integer arrays/lists.

  • Read the number of test cases

  • For each test case, read the size and elements of the first array/list

  • Read the size and elements of the second array/list

  • Find the intersection of the two arrays/lists

  • Print the intersection elements in the order they appear in the first array/list

Asked in GlobalLogic

3d ago

Q. Find Terms of Series Problem

Ayush is tasked with determining the first 'X' terms of the series defined by 3 * N + 2, ensuring that no term is a multiple of 4.

Input:

The first line contains a single integer 'T...read more
Ans.

Generate the first 'X' terms of a series 3 * N + 2, excluding multiples of 4.

  • Iterate through numbers starting from 1 and check if 3 * N + 2 is not a multiple of 4.

  • Keep track of the count of terms generated and stop when 'X' terms are found.

  • Return the list of 'X' terms that meet the criteria.

  • Example: For X = 4, the output should be [5, 11, 14, 17].

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Asked in Mr Cooper

3d ago

Q. Connect Ropes Problem Statement

Given a number of ropes denoted as 'N' and an array containing the lengths of these ropes, your task is to connect the ropes into one single rope. The cost to connect two ropes i...read more

Ans.

The task is to find the minimum cost required to connect all the ropes by summing their lengths.

  • Iterate through the ropes and connect the two shortest ropes at each step to minimize cost

  • Use a priority queue to efficiently find the shortest ropes

  • Keep track of the total cost as you connect the ropes

  • Example: For input [4, 3, 2, 6], connect 2 and 3 (cost 5), then connect 4 and 5 (cost 9), then connect 9 and 6 (cost 15) for a total cost of 29

Asked in Infosys

2d ago

Q. String Compression Problem Statement

Ninja needs to perform basic string compression. For any character that repeats consecutively more than once, replace the repeated sequence with the character followed by th...read more

Ans.

Implement a function to compress a string by replacing consecutive characters with the character followed by the count of repetitions.

  • Iterate through the input string and keep track of consecutive characters and their counts.

  • Replace consecutive characters with the character followed by the count of repetitions if count is greater than 1.

  • Return the compressed string as output.

Asked in IQVIA

5d ago

Q. Palindromic Numbers Finder

Given an integer 'N', your task is to identify all palindromic numbers from 1 to 'N'. These are numbers that read the same way forwards and backwards.

Input:

The first line provides a...read more
Ans.

Implement a function to find all palindromic numbers from 1 to N.

  • Iterate from 1 to N and check if each number is a palindrome

  • Use string manipulation to check for palindromes

  • Consider edge cases like single-digit numbers and 11

6d ago

Q. Validate Binary Tree Nodes Problem

You are provided with 'N' binary tree nodes labeled from 0 to N-1, where node i has two potential children, recorded in the LEFT_CHILD[i] and RIGHT_CHILD[i] arrays. Determine ...read more

Ans.

The task is to determine if the given binary tree nodes form exactly one valid binary tree.

  • Check if there is only one root node (a node with no parent)

  • Check if each node has at most one parent

  • Check if there are no cycles in the tree

  • Check if all nodes are connected and form a single tree

Asked in Amazon

3d ago

Q. Fenwick Tree Problem Statement

You are provided with an array/list ARR consisting of 'N' integers, along with 'Q' queries. Each query can be of one of the following two types:

  • Type 1 (Range Sum): Given two int...read more
Ans.

Implement Fenwick Tree to handle range sum and point update queries on an array.

  • Implement Fenwick Tree data structure to efficiently handle range sum and point update queries.

  • For range sum queries, use prefix sum technique to calculate the sum of elements in the given range.

  • For point update queries, update the Fenwick Tree structure accordingly.

  • Handle each query type separately and output the required results.

  • Ensure to follow the constraints provided in the problem statement.

Asked in Wipro

4d ago

Q. Minimum Operations to Make Strings Equal

Given two strings, A and B, consisting of lowercase English letters, determine the minimum number of pre-processing moves required to make string A equal to string B usi...read more

Ans.

Determine the minimum number of pre-processing moves required to make two strings equal by swapping characters and replacing characters in one string.

  • Iterate through both strings simultaneously and count the number of characters that need to be swapped.

  • Consider all possible swaps and replacements to find the minimum number of pre-processing moves.

  • If the lengths of the strings are different, it's impossible to make them equal.

  • Handle edge cases like empty strings or strings wit...read more

Asked in Adobe

3d ago

Q. Search In Rotated Sorted Array Problem Statement

Given a sorted array of distinct integers that has been rotated clockwise by an unknown amount, you need to search for a specified integer in the array. For each...read more

Ans.

Implement a search function to find a specified integer in a rotated sorted array.

  • Implement a binary search algorithm to find the target integer in the rotated sorted array.

  • Handle the cases where the target integer may lie in the left or right half of the array after rotation.

  • Keep track of the mid element and adjust the search space based on the rotation.

  • Return the index of the target integer if found, else return -1.

Asked in Samsung

1d ago

Q. Triplets with Given Sum Problem

Given an array or list ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a specified number K.

Explanation:

A triplet i...read more

Ans.

The task is to find all distinct triplets in an array that sum up to a specified number.

  • Iterate through all possible triplets using three nested loops.

  • Check if the sum of the triplet equals the target sum.

  • Print the triplet if found, else print -1.

  • Handle duplicate triplets by skipping duplicates during iteration.

Asked in Infosys

2d ago

Q. 1. what is the difference between exception and error. How did u solve the errors in the code deployment?

Ans.

Exception is a runtime error that can be handled, while error is a severe issue that cannot be handled.

  • Exceptions are caused by the program logic, while errors are caused by external factors like hardware failure or network issues.

  • Exceptions can be caught and handled using try-catch blocks, while errors require fixing the underlying issue.

  • Example of exception: NullPointerException. Example of error: Out of Memory Error.

  • To solve errors in code deployment, identify the root cau...read more

Asked in GlobalLogic

1d ago

Q. Reverse Array Elements

Given an array containing 'N' elements, the task is to reverse the order of all array elements and display the reversed array.

Explanation:

The elements of the given array need to be rear...read more

Ans.

Reverse the order of elements in an array and display the reversed array.

  • Iterate through the array from both ends and swap the elements until reaching the middle.

  • Use a temporary variable to store the element being swapped.

  • Print the reversed array after swapping all elements.

Asked in Adobe

1d ago

Q. Wildcard Pattern Matching Problem Statement

Implement a wildcard pattern matching algorithm to determine if a given wildcard pattern matches a text string completely.

The wildcard pattern may include the charac...read more

Ans.

Implement a wildcard pattern matching algorithm to determine if a given wildcard pattern matches a text string completely.

  • Create a recursive function to match the pattern with the text character by character

  • Handle cases for '?' and '*' characters in the pattern

  • Keep track of the current position in both pattern and text strings

  • Return 'True' if the pattern matches the text completely, otherwise return 'False'

Asked in Nagarro

5d ago

Q. Ninja and the New Year Guests Problem

Ninja has organized a new year party and wants to verify if the guests are programmers by challenging them with a coding task. As an invited programmer, you're tasked to so...read more

Ans.

Compute the number of valid permutations of integers from 0 to N-1 such that at least K positions satisfy ARR[I] = I.

  • Use dynamic programming to solve the problem efficiently.

  • Consider the cases where K is equal to N or N-1 separately.

  • Modulo the result by 10^9 + 7 to avoid overflow issues.

Asked in Amazon

5d ago

Q. Sort 0s, 1s, and 2s Problem Statement

You are provided with an integer array/list ARR of size 'N' which consists solely of 0s, 1s, and 2s. Your task is to write a solution to sort this array/list.

Input:

The fi...read more
Ans.

Sort an array of 0s, 1s, and 2s in linear time with a single scan approach.

  • Use three pointers to keep track of the positions of 0s, 1s, and 2s in the array.

  • Iterate through the array once and swap elements based on their values and the pointers.

  • After the single scan, the array will be sorted in place with 0s, 1s, and 2s in order.

1d ago

Q. Check Permutation Problem

Determine if two given strings, str1 and str2, are permutations of each other.

Explanation:

Two strings are permutations of each other if the characters of one string can be rearranged...read more

Ans.

Check if two strings are permutations of each other.

  • Create character frequency maps for both strings.

  • Compare the frequency maps to check if they are permutations.

  • Handle edge cases like empty strings or strings of different lengths.

4d ago

Q. Maximum Subarray Problem Statement

Ninja has been given an array, and he wants to find a subarray such that the sum of all elements in the subarray is maximum.

A subarray 'A' is considered greater than a subarr...read more

Ans.

The task is to find the subarray with the maximum sum in a given array.

  • Iterate through the array and keep track of the current sum and maximum sum seen so far.

  • If the current sum becomes negative, reset it to 0 as it won't contribute to the maximum sum.

  • Compare the maximum sum with the sum of the current subarray to update the result.

  • Handle cases where all elements are negative by returning the maximum element in the array.

  • Consider edge cases like empty array or array with only...read more

Asked in Amazon

2d ago

Q. Missing Number Problem Statement

You are provided with an array named BINARYNUMS consisting of N unique strings. Each string represents an integer in binary, covering every integer from 0 to N except for one. Y...read more

Ans.

Find the missing integer in binary form from an array of unique binary strings.

  • Iterate through the array of binary strings and convert each string to its decimal equivalent.

  • Calculate the sum of all integers from 0 to N using the formula (N * (N + 1)) / 2.

  • Subtract the sum of the integers represented by the binary strings from the total sum to find the missing integer.

  • Convert the missing integer to binary form and return it as a string without leading zeros.

Asked in Practo

4d ago

Q. Intersection of Two Unsorted Arrays Problem Statement

Given two integer arrays ARR1 and ARR2 of sizes 'N' and 'M' respectively, find the intersection of these arrays. The intersection is defined as the set of e...read more

Ans.

Find the intersection of two unsorted arrays while maintaining the order of elements from the first array.

  • Iterate through the elements of the first array and check if they exist in the second array.

  • Use a hash set to keep track of elements already seen in the second array for efficient lookup.

  • Maintain the order of elements from the first array while finding the intersection.

  • Handle duplicate elements in both arrays appropriately.

  • Output the intersection elements in the order the...read more

Asked in Oracle

2d ago

Q. Greatest Common Divisor Problem Statement

You are tasked with finding the greatest common divisor (GCD) of two given numbers 'X' and 'Y'. The GCD is defined as the largest integer that divides both of the given...read more

Ans.

Find the greatest common divisor (GCD) of two given numbers 'X' and 'Y'.

  • Iterate from 1 to the minimum of X and Y, check if both X and Y are divisible by the current number, update GCD if true

  • Use Euclidean algorithm to find GCD: GCD(X, Y) = GCD(Y, X % Y)

  • If one of the numbers is 0, the other number is the GCD

  • Handle edge cases like when one of the numbers is 0 or negative

2d ago

Q. Buses Origin Problem Statement

You have been provided with an array where each element specifies the number of buses that can be boarded at each respective bus stop. Buses will only stop at locations that are m...read more

Ans.

Given an array representing number of buses at each bus stop, determine how many buses originate from each stop.

  • Iterate through the array and for each element, increment the count of buses originating from the corresponding bus stop.

  • Use an array to store the count of buses originating from each stop.

  • Remember to consider the constraint of 1-based indexing for bus stops.

1d ago

Q. Find K'th Character of Decrypted String

You are given an encrypted string where repeated substrings are represented by the substring followed by its count. Your task is to find the K'th character of the decrypt...read more

Ans.

Given an encrypted string with repeated substrings represented by counts, find the K'th character of the decrypted string.

  • Parse the encrypted string to extract substrings and their counts

  • Iterate through the substrings and counts to build the decrypted string

  • Track the position in the decrypted string to find the K'th character

Asked in Cohesity

4d ago

Q. Balanced Sequence After Replacement

Given a string of length 'N' containing only the characters: '[', '{', '(', ')', '}', ']'. At certain places, the character 'X' appears in place of any bracket. Your goal is ...read more

Ans.

Determine if a valid balanced sequence can be achieved by replacing 'X's with suitable brackets.

  • Iterate through the string and keep track of the count of opening and closing brackets.

  • If at any point the count of closing brackets exceeds the count of opening brackets, return False.

  • If all 'X's can be replaced to form a valid balanced sequence, return True.

Asked in Amazon

3d ago

Q. Flip Bits Problem Explanation

Given an array of integers ARR of size N, consisting of 0s and 1s, you need to select a sub-array and flip its bits. Your task is to return the maximum count of 1s that can be obta...read more

Ans.

Maximize the count of 1s in a binary array by flipping a sub-array of 0s to 1s at most once.

  • Initial Count: Start by counting the number of 1s in the original array.

  • Flipping Logic: For each sub-array, calculate the effect of flipping 0s to 1s and 1s to 0s.

  • Kadane's Algorithm: Use a modified version of Kadane's algorithm to find the maximum gain from flipping a sub-array.

  • Edge Cases: Consider cases where the array is all 1s or all 0s.

  • Example: For ARR = [1, 0, 0, 1], flipping the ...read more

1
2
3
4
5
6
7
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 & Stories
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
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