Software Developer
8000+ Software Developer Interview Questions and Answers

Asked in Amazon

Q. Search for Indices with Given Difference and Distance
You are provided with an array containing 'N' non-negative integers, along with two other non-negative integers 'K' and 'M'. Your task is to identify and re...read more
Find a pair of indices in an array with given difference and distance constraints.
Iterate through the array and check all possible pairs of indices to satisfy the conditions
Use nested loops to compare each pair of indices and their corresponding elements
Return 'valid' if a pair of indices is found that meets the conditions, otherwise return 'invalid'

Asked in Think Future Technologies

Q. Split Array with Equal Sums Problem Statement
Given an array 'ARR' of size 'N', determine if there exists a triplet (i, j, k) satisfying the conditions: 0 < i , i + 1 < j , j + 1 < k and k < N - 1, such that th...read more
The problem involves determining if there exists a triplet in an array such that the sums of specific subarrays are equal.
Iterate through all possible triplets (i, j, k) satisfying the given conditions.
Calculate the sum of subarrays [0, i - 1], [i + 1, j - 1], [j + 1, k - 1], [k + 1, N - 1] for each triplet.
Check if any triplet has equal sums for the subarrays, return True if found, else False.

Asked in LTIMindtree

Q. Sum of Squares of First N Natural Numbers Problem Statement
You are tasked with finding the sum of squares of the first N
natural numbers for given test cases.
Input:
The first line contains an integer 'T', the...read more
Calculate the sum of squares of the first N natural numbers for given test cases.
Read the number of test cases 'T'
For each test case, read the value of 'N'
Calculate the sum of squares of the first 'N' natural numbers
Output the result for each test case

Asked in ION Group

Q. Trapping Rain Water in 2-D Elevation Map
You're given an M * N matrix where each value represents the height of that cell on a 2-D elevation map. Your task is to determine the total volume of water that can be ...read more
Calculate the total volume of water that can be trapped in a 2-D elevation map after rain.
Iterate over the matrix and find the maximum height on the borders.
Calculate the water trapped at each cell by finding the difference between the cell's height and the minimum of its neighboring maximum heights.
Sum up the trapped water for all cells to get the total volume of water trapped.
Asked in Iris Healthcare Technologies

Q. Q1. Why is String Immutable? What is String Pool? How to create a String which is not stored in String Pool? What is REST Web Service? Life Cycle of a thread? If Rest is Stateless How do you maintain Sessions?...
read moreWhat is the difference between abstract class and interface?
Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.
A class can implement multiple interfaces, but can only extend one abstract class.
Abstract classes can have constructors, while interfaces cannot.
Interfaces are used to achieve multiple inheritance in Java.
Example: Abstract class - Animal, Interface - Flyable
Example: Abstract class - Shape, Interface - Drawa...read more

Asked in ShareChat

Q. Aggressive Cows Problem Statement
Given an array representing positions of stalls and an integer ‘K’ representing the number of aggressive cows, determine the largest minimum distance between any two cows when ...read more
The problem is to assign aggressive cows to stalls in a way that maximizes the minimum distance between any two cows.
Sort the array of stall positions in ascending order.
Use binary search to find the largest minimum distance between cows.
Check if it is possible to assign cows with this minimum distance by iterating through the sorted array.
If it is possible, update the maximum distance and continue binary search for a larger minimum distance.
If it is not possible, continue bi...read more
Software Developer Jobs




Asked in Bank of America

Q. Alternate Print Problem Statement
Given two strings A
and B
, your task is to print these two strings in an alternating sequence by indices. That is, the first character of 'A', the first character of 'B', follo...read more
The task is to print two strings in an alternating sequence by indices.
Iterate through both strings simultaneously and append characters alternately
Handle the case where one string is longer than the other
Use two pointers to keep track of the current index in each string

Asked in Cisco

Q. Apple Pickup Problem Statement
Alice has a garden represented as a ‘N’ * ‘N’ grid called ‘MATRIX’. She wants to collect apples following these rules:
1
-> Alice can pick an apple from this cell and pass throug...read more
The problem involves finding the maximum number of apples Alice can collect in a grid while following specific rules.
Create a recursive function to explore all possible paths from the starting point to the ending point while keeping track of the collected apples.
Consider the constraints and optimize the solution to avoid unnecessary computations.
Use dynamic programming to store and reuse the results of subproblems to improve efficiency.
Ensure to handle cases where there is no...read more
Share interview questions and help millions of jobseekers 🌟

Asked in UnitedHealth

Q. Bubble Sort Problem Statement
Sort an unsorted array of non-negative integers using the Bubble Sort algorithm, which swaps adjacent elements if they are not in the correct order to sort the array in non-decreas...read more
Bubble Sort is used to sort an unsorted array of non-negative integers in non-decreasing order by swapping adjacent elements.
Iterate through the array and compare adjacent elements, swapping them if they are not in the correct order.
Repeat this process until the array is sorted in non-decreasing order.
Time complexity of Bubble Sort is O(n^2) in worst case.
Space complexity of Bubble Sort is O(1) as it sorts the array in place.

Asked in Meesho

Q. Idempotent Matrix Verification
Determine if a given N * N matrix is an idempotent matrix. A matrix is considered idempotent if it satisfies the following condition:
M * M = M
Input:
The first line contains a si...read more
Check if a given matrix is idempotent by verifying if M * M = M.
Iterate through the matrix and multiply it with itself to check if it equals the original matrix.
If the condition M * M = M is satisfied, then the matrix is idempotent.
If the condition is not satisfied, then the matrix is not idempotent.

Asked in Amazon

Q. Kth Smallest Element in an Unsorted Array
Given an unsorted array arr
of distinct integers and an integer k
, your task is to find the k-th
smallest element in the array.
Input:
The first line of input contains ...read more
Find the k-th smallest element in an unsorted array of distinct integers.
Sort the array and return the k-th element.
Use a priority queue or quickselect algorithm for efficient solution.
Handle edge cases like k being out of bounds or array being empty.

Asked in Adobe

Q. Minimum Fountains Activation Problem
In this problem, you have a one-dimensional garden of length 'N'. Each position from 0 to 'N' has a fountain that can provide water to the garden up to a certain range. Thus...read more
Find the minimum number of fountains to activate to water the entire garden.
Iterate through the array to find the coverage of each fountain.
Keep track of the farthest coverage reached by activating fountains.
Activate the fountain that covers the farthest point not yet covered.
Repeat until the entire garden is watered.

Asked in Standard Chartered

Q. Occurrence of Each Word: Problem Statement
You are given a string S
consisting of several words. Your task is to count the number of times each word appears in string S
. A word is defined as a sequence of one o...read more
Count the occurrence of each word in a given string.
Split the string into words using spaces as delimiters.
Use a hashmap to store the count of each word.
Iterate through the words and update the count in the hashmap.
Output each unique word with its occurrence count.

Asked in BNY

Q. Palindromic Substrings Problem Statement
You are given a string 'STR'. Your task is to determine the total number of palindromic substrings present in 'STR'.
Example:
Input:
"abbc"
Output:
5
Explanation:
The pa...read more
Count the total number of palindromic substrings in a given string.
Iterate through each character in the string and expand around it to find palindromic substrings.
Use dynamic programming to store the results of subproblems to avoid redundant calculations.
Consider both odd and even length palindromes while counting.
Example: For input 'abbc', the palindromic substrings are ['a', 'b', 'b', 'c', 'bb'], totaling 5.

Asked in Amazon

Q. Sum of Minimum and Maximum Elements of All Subarrays of Size K
You are provided with an array containing N integers along with an integer K. Your task is to compute the total sum of the minimum and maximum elem...read more
Calculate the sum of minimum and maximum elements of all subarrays of size K in an array.
Iterate through the array and maintain a deque to store the indices of elements in the current window of size K.
Keep track of the minimum and maximum elements in the current window using the deque.
Calculate the sum of minimum and maximum elements for each subarray of size K and return the total sum.

Asked in Morgan Stanley

Q. Find the Duplicate Number Problem Statement
Given an integer array 'ARR' of size 'N' containing numbers from 0 to (N - 2). Each number appears at least once, and there is one number that appears twice. Your tas...read more
Find the duplicate number in an array of integers from 0 to N-2.
Iterate through the array and keep track of the frequency of each number using a hashmap.
Return the number with a frequency greater than 1 as the duplicate number.
Alternatively, use Floyd's Tortoise and Hare algorithm to find the duplicate number in O(N) time and O(1) space.

Asked in Daffodil Software

Q. Find the Longest Palindromic Substring
Given a string ‘S’ composed of lowercase English letters, your task is to identify the longest palindromic substring within ‘S’.
If there are multiple longest palindromic ...read more
Find the longest palindromic substring in a given string, returning the rightmost one if multiple substrings are of the same length.
Iterate through each character in the string and expand around it to find palindromic substrings
Keep track of the longest palindromic substring found so far
Return the rightmost longest palindromic substring

Asked in ACKO

Q. Flip Equivalent Binary Tree Problem
Determine whether two binary trees, given by their roots 'ROOT1' and 'ROOT2', are flip equivalent. A tree can be transformed into a flip equivalent through any number of flip...read more
The problem is to determine if two binary trees are flip equivalent after performing flip operations on one of the trees.
Perform a depth-first search (DFS) on both trees simultaneously
At each node, check if the values are equal and the left and right subtrees are either both null or both not null
If the above conditions are met, recursively check the flip equivalence of the left and right subtrees
If any of the conditions fail at any node, the trees are not flip equivalent

Asked in SAP

Q. Given a 10-digit number, sort the individual digits of the number.
Sort the individual digits of a 10 digit number.
Convert the number to a string to access individual digits
Use a sorting algorithm to sort the digits
Convert the sorted digits back to a number

Asked in Bharti Airtel

Q. Longest Subarray with Zero Sum
Ninja enjoys working with numbers, and as a birthday challenge, his friend provides him with an array consisting of both positive and negative integers. Ninja is curious to identi...read more
Find the length of the longest subarray with zero sum in an array of integers.
Iterate through the array and keep track of the running sum using a hashmap.
If the running sum is seen before, the subarray between the current index and the previous index with the same sum is a subarray with zero sum.
Update the length of the longest subarray with zero sum as you iterate through the array.
Example: For arr1 = [1, -1, 3, 2, -2, -3, 3], the longest subarray with zero sum is [3, 2, -2,...read more

Asked in TCS

Q. Maximum Vehicle Registrations Problem
Bob, the mayor of a state, seeks to determine the maximum number of vehicles that can be uniquely registered. Each vehicle's registration number is structured as follows: S...read more
Calculate the maximum number of unique vehicle registrations based on given constraints.
Parse input for number of test cases, district count, letter ranges, and digit ranges.
Calculate the total number of unique registrations based on the given constraints.
Output the maximum number of unique vehicle registrations for each test case.

Asked in Cvent

Q. Meeting Rescheduling Challenge
Ninja is tasked with organizing a meeting in an office that starts at time ‘0’ and ends at time ‘LAST’. There are ‘N’ presentations scheduled with given start and end times. The p...read more
Reschedule at most K presentations to maximize longest gap without overlap.
Iterate through presentations and calculate the gap between each pair of presentations
Sort the presentations by their start times and keep track of the longest gap
Reschedule at most K presentations to maximize the longest gap without overlap

Asked in Athenahealth Technology

Q. Rectangular Numbers Problem Statement
Ninja has a number 'N'. Your task is to generate a pattern where the outer rectangle is filled with the number 'N', and as you move inward, the numbers decrease consecutive...read more
Generate a pattern with outer rectangle filled with number 'N' and decreasing consecutively inward.
Start by filling the outermost rectangle with the number 'N'.
Decrease the numbers consecutively as you move inward towards the center.
Continue this pattern until you reach the center of the rectangle.

Asked in Microsoft Corporation

Q. Spiral Matrix Problem Statement
You are provided with a 2-D array called MATRIX
with dimensions N x M containing integers. Your task is to return the matrix's elements in a spiral order.
Example:
Input:
The fi...read more
The task is to return the elements of a 2-D array in a spiral order.
Traverse the matrix in a spiral order by moving right, down, left, and up.
Keep track of the boundaries of the matrix as you move along.
Handle cases where the matrix is not a square (N != M).

Asked in Josh Technology Group

Q. Wave Array Sorting Problem
Your goal is to sort a given unsorted array ARR
such that it forms a wave array.
Explanation:
After sorting, the array should satisfy the wave pattern conditions:
ARR[0] >= ARR[1]
AR...read more
The task is to sort an array in a wave form, where each element is greater than or equal to its adjacent elements.
Iterate through the array and swap adjacent elements if they do not follow the wave pattern
Start from the second element and compare it with the previous element, swap if necessary
Continue this process until the end of the array
Repeat the process for the remaining elements
Return the sorted wave array

Asked in Amazon

Q. Best Time To Buy and Sell Stock Problem Statement
You are given an array 'PRICES' of 'N' integers, where 'PRICES[i]' represents the price of a certain stock on the i-th day. An integer 'K' is also provided, ind...read more
Determine the maximum profit achievable with at most K transactions by buying and selling stocks.
Iterate through the array and keep track of the minimum price to buy and maximum profit to sell.
Use dynamic programming to calculate the maximum profit with at most K transactions.
Consider edge cases like when K is 0 or when the array is empty.
Example: For input N = 6, PRICES = [3, 2, 6, 5, 0, 3], K = 2, the output should be 7.

Asked in Wipro

Q. K-th Permutation Sequence Problem Statement
Given two integers N
and K
, your task is to find the K-th permutation sequence of numbers from 1 to N
. The K-th permutation is the K-th permutation in the set of all ...read more
Find the K-th permutation sequence of numbers from 1 to N.
Generate all permutations of numbers from 1 to N using backtracking or next_permutation function.
Sort the permutations in lexicographical order.
Return the K-th permutation from the sorted list.

Asked in Amazon

Q. Max GCD Pair Problem Statement
Given an array of positive integers, determine the Greatest Common Divisor (GCD) of a pair of elements such that it is the maximum among all possible pairs in the array. The GCD o...read more
Find the maximum GCD of a pair of elements in an array of positive integers.
Iterate through all pairs of elements in the array
Calculate the GCD of each pair using Euclidean algorithm
Keep track of the maximum GCD found
Return the maximum GCD value

Asked in Directi

Q. Maximum Sum Subarray Problem Statement
Given an array of integers, find the maximum sum of any contiguous subarray within the array.
Example:
Input:
array = [34, -50, 42, 14, -5, 86]
Output:
137
Explanation:
Th...read more
Find the maximum sum of any contiguous subarray within an array in O(N) time complexity.
Use Kadane's algorithm to find the maximum sum subarray in O(N) time complexity
Initialize two variables: max_sum and current_sum to keep track of the maximum sum subarray
Iterate through the array and update current_sum by adding the current element or starting a new subarray
Update max_sum if current_sum is greater than max_sum
Return max_sum as the maximum sum of any contiguous subarray

Asked in WatchGuard Technologies

Q. Move Zeros to Left Problem Statement
Your task is to rearrange a given array ARR
such that all zero elements appear at the beginning, followed by non-zero elements, while maintaining the relative order of non-z...read more
Rearrange an array to move all zeros to the left while maintaining the relative order of non-zero elements.
Iterate through the array and maintain two pointers, one for zeros and one for non-zeros.
Swap elements at the two pointers if the current element is non-zero.
Continue until all elements are rearranged according to the problem statement.
Interview Questions of Similar Designations
Interview Experiences of Popular Companies





Top Interview Questions for Software Developer Related Skills

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

