Software Developer
1500+ Software Developer Interview Questions and Answers for Freshers

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 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 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.
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 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.
Share interview questions and help millions of jobseekers 🌟

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 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 requires assigning 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.
Return the maximum distance ...read more

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 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 Cognizant

Q. Nth Fibonacci Number Problem Statement
Given an integer 'N', the task is to compute the N'th Fibonacci number using matrix exponentiation. Implement and return the Fibonacci value for the provided 'N'.
Note:
Si...read more
Use matrix exponentiation to efficiently compute the Nth Fibonacci number modulo 10^9 + 7.
Implement matrix exponentiation to calculate Fibonacci numbers efficiently.
Use the formula F(n) = F(n-1) + F(n-2) with initial values F(1) = F(2) = 1.
Return the result modulo 10^9 + 7 to handle large Fibonacci numbers.
Optimize the solution to achieve better than O(N) time complexity.

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

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

Asked in Adobe

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

Asked in Google

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 moreFind 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 Ansys Software Private Limited

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
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 Tata 1mg

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

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
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 Bottomline

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
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 Accenture

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

Asked in Swiggy

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

