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

Asked in Raja Software Labs

Q. Fibonacci Membership Check
Given an integer N
, determine if it is a member of the Fibonacci series. Return true
if the number is a member of the Fibonacci series, otherwise return false
.
Fibonacci Series Defini...read more
Check if a given integer is a member of the Fibonacci series.
Implement a function to check if the given number is a perfect square.
Check if 5*N^2 + 4 or 5*N^2 - 4 is a perfect square to determine Fibonacci membership.
Return true if the number is a perfect square of 5*N^2 + 4 or 5*N^2 - 4, otherwise false.

Asked in Josh Technology Group

Q. Balanced Binary Trees Problem Statement
You are provided with an integer 'H'. Your task is to determine and print the maximum number of balanced binary trees possible with height 'H'.
A balanced binary tree is ...read more
The maximum number of balanced binary trees possible with a given height is to be counted and printed.
A balanced binary tree is one in which the difference between the left and right subtree heights is less than or equal to 1.
The number of balanced binary trees can be calculated using dynamic programming.
The number of balanced binary trees with height 'H' can be obtained by summing the product of the number of balanced binary trees for each possible left and right subtree hei...read more

Asked in Nvidia

Q. Order of People Heights Problem Statement
Consider 'N' individuals numbered from 0 to N-1 standing in a queue. You are provided with two arrays: Height
and Infront
, each consisting of 'N' non-negative integers....read more
The task is to find the actual order of people in a queue based on their heights and the number of taller people in front of them.
Iterate through the given arrays and create a list of tuples containing the height and number of taller people for each person.
Sort the list of tuples in descending order of height and ascending order of the number of taller people.
Create an empty result list and insert each tuple into the result list at the index specified by the number of taller ...read more

Asked in Josh Technology Group

Q. 0/1 Knapsack Problem Statement
A thief is planning to rob a store and can carry a maximum weight of 'W' in his knapsack. The store contains 'N' items where the ith item has a weight of 'wi' and a value of 'vi'....read more
Yes, the 0/1 Knapsack problem can be solved using dynamic programming with a space complexity of not more than O(W).
Use a 1D array to store the maximum value that can be stolen for each weight from 0 to W.
Iterate through each item and update the array based on whether including the item would increase the total value.
The final value in the array at index W will be the maximum value that can be stolen.

Asked in Oyo Rooms

Q. First Unique Character in a Stream Problem Statement
Given a string A
consisting of lowercase English letters, determine the first non-repeating character at each point in the stream of characters.
Example:
Inp...read more
Given a string of lowercase English letters, find the first non-repeating character at each point in the stream.
Create a hashmap to store the frequency of each character as it appears in the stream.
Iterate through the stream and check the frequency of each character to find the first non-repeating character.
Output the first non-repeating character at each point in the stream.

Asked in Bharti Airtel

Q. Longest Common Prefix After Rotation
You are given two strings 'A' and 'B'. While string 'A' is constant, you may apply any number of left shift operations to string 'B'.
Explanation:
Your task is to calculate ...read more
Calculate the minimum number of left shift operations needed to achieve the longest common prefix between two strings.
Apply left shift operations to string B to find the longest common prefix with string A
Count the number of left shifts needed to achieve the longest common prefix
Return the minimum number of left shift operations for each test case
Software Developer Jobs




Asked in Nagarro

Q. Maximum Meetings Problem Statement
Given the schedule of N meetings with their start time Start[i]
and end time End[i]
, you need to determine which meetings can be organized in a single meeting room such that t...read more
Given N meetings with start and end times, find the maximum number of meetings that can be organized in a single room without overlap.
Sort the meetings based on their end times.
Iterate through the sorted meetings and select the next meeting that does not overlap with the current meeting.
Keep track of the selected meetings and return their indices in the order they are organized.

Asked in Amazon

Q. Pair Sum Problem Statement
You are provided with an array ARR
consisting of N
distinct integers in ascending order and an integer TARGET
. Your objective is to count all the distinct pairs in ARR
whose sum equal...read more
Count distinct pairs in an array whose sum equals a given target.
Use two pointers approach to iterate through the array and find pairs with sum equal to target.
Keep track of visited pairs to avoid counting duplicates.
Return -1 if no such pair exists with the given target.
Share interview questions and help millions of jobseekers 🌟

Asked in Nagarro

Q. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
The question asks to find the total amount of rainwater that can be trapped in the given elevation map.
Iterate through the array and find the maximum height on the left and right side of each bar.
Calculate the amount of water that can be trapped on each bar by subtracting its height from the minimum of the maximum heights on both sides.
Sum up the amount of water trapped on each bar to get the total amount of rainwater trapped.

Asked in Amazon

Q. Balanced Parentheses Combinations
Given an integer N
representing the number of pairs of parentheses, find all the possible combinations of balanced parentheses using the given number of pairs.
Explanation:
Con...read more
Generate all possible combinations of balanced parentheses for a given number of pairs.
Use backtracking to generate all possible combinations of balanced parentheses.
Keep track of the number of open and close parentheses used in each combination.
Recursively generate combinations by adding open parentheses if there are remaining, and close parentheses if the number of open parentheses is greater than the number of close parentheses.

Asked in SAP

Q. Duplicate Integer in Array
Given an array ARR
of size N
, containing each number between 1 and N-1
at least once, identify the single integer that appears twice.
Input:
The first line contains an integer, 'T', r...read more
Identify the duplicate integer in an array containing numbers between 1 and N-1.
Iterate through the array and keep track of the frequency of each element using a hashmap.
Return the element with a frequency greater than 1 as the duplicate integer.
Time complexity can be optimized to O(N) using Floyd's Tortoise and Hare algorithm.
Example: For input [1, 2, 3, 4, 4], the output should be 4.

Asked in OodlesTechnologies

Q. Find a Node in Linked List
Given a singly linked list of integers, your task is to implement a function that returns the index/position of an integer value 'N' if it exists in the linked list. Return -1 if the ...read more
Implement a function to find the index of a given integer in a singly linked list.
Traverse the linked list while keeping track of the index of each element.
Compare each element with the target integer 'N'.
Return the index if 'N' is found, otherwise return -1.
Handle cases where the list is empty or 'N' is not found.
Consider the constraints on the number of test cases and the length of the linked list.

Asked in Adobe

Q. Morty's Array Challenge
Rick has provided Morty with an array 'Arr' of length 'N' and an integer 'K'. Morty needs to split the array into non-empty sub-arrays to achieve the minimum possible cost, subject to th...read more
The challenge involves splitting an array into sub-arrays to minimize cost based on unique elements and repetitions.
Iterate through the array and keep track of unique elements and repetitions
Calculate cost for each sub-array based on the rules provided
Sum up the costs for all sub-arrays to get the total minimum cost

Asked in Cuemath

Q. N-th Term Of Geometric Progression
Find the N-th term of a Geometric Progression (GP) series given the first term A, the common ratio R, and the term position N.
Explanation:
The general form of a GP series is ...read more
Calculate the N-th term of a Geometric Progression series given the first term, common ratio, and term position.
Use the formula A * R^(N-1) to find the N-th term of the GP series.
Remember to return the result modulo 10^9 + 7 as the term can be very large.
Handle multiple test cases efficiently by iterating through each case.

Asked in HexaView Technologies

Q. Number Pattern Problem Statement
Design a seating arrangement for a high-security meeting. There are 'N' rows of tables set up where the first row contains one table, the second row contains two tables, and so ...read more
Design a seating arrangement for a high-security meeting with specific table assignments for security personnel and guests.
Create a loop to iterate through each row from 1 to N.
Assign tables on either end of each row to security personnel.
For rows with only one table, assign it to security personnel.
Display the seating arrangement with the number of people at each table.
Example: For 4 rows, the output pattern is 1, 11, 121, 1221.

Asked in DE Shaw

Q. Rabbit Jumping Problem
Consider 'n' carrots numbered from 1 to 'n' and 'k' rabbits. Each rabbit jumps to carrots only at multiples of its respective jumping factor Aj (i.e., Aj, 2Aj, 3Aj, ...), for all rabbits ...read more
Calculate uneaten carrots by rabbits with specific jumping factors.
Iterate through each carrot and check if any rabbit jumps on it.
Use the jumping factors to determine which carrots will be eaten.
Subtract the eaten carrots from the total to get the uneaten carrots.

Asked in GlobalLogic

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
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 the middle is reached.
Use a temporary variable to store the element being swapped.
Print the reversed array after all elements have been swapped.

Asked in upGrad

Q. Sort 0 and 1 Problem Statement
Given an integer array ARR
of size N
containing only integers 0 and 1, implement a function to sort this array. The solution should scan the array only once without using any addi...read more
Sort an array of 0s and 1s in linear time without using additional arrays.
Iterate through the array and maintain two pointers, one for 0s and one for 1s.
Swap elements at the two pointers based on the current element being 0 or 1.
Continue this process until the entire array is sorted in place.

Asked in TCS

Q. Strings of Numbers Problem Statement
You are given two integers 'N' and 'K'. Consider a set 'X' of all possible strings of 'N' number of digits where all strings only contain digits ranging from 0 to 'K' inclus...read more
The task is to find a string of minimal length that includes every possible string of N digits with digits ranging from 0 to K as substrings.
Generate all possible strings of N digits with digits from 0 to K
Concatenate these strings in a way that all are substrings of the final string
Return 1 if the final string contains all possible strings, else return 0

Asked in Microsoft Corporation

Q. A file or a directory can be represented as a node with properties like ID, parent ID, name, and number of children (0 for a file). The file structure is a linked list of nodes where the parent directory always...
read moreImplement a GUI to display a file structure using a linked list of nodes representing files and directories.
Each node has properties: ID, parent ID, name, and number of children.
The linked list maintains the order: parent directories appear before their children.
To display children, traverse the linked list and check for matching parent IDs.
Example: For a parent node with ID 1, find all nodes with parent ID 1 to display its children.
Use a recursive function to handle expandin...read more

Asked in Amazon

Q. Delete Alternate Nodes from a Singly Linked List
Given a Singly Linked List of integers, remove all the alternate nodes from the list.
Input:
The first and the only line of input will contain the elements of th...read more
Remove alternate nodes from a singly linked list of integers.
Traverse the linked list and skip every alternate node while updating the next pointers.
Make sure to handle cases where there are less than 3 nodes in the list.
Update the next pointers accordingly to remove alternate nodes.
Example: Input: 10 20 30 40 50 60 -1, Output: 10 30 50

Asked in Urban Company

Q. Meeting Rooms Allocation Problem Statement
Stark Industry is planning to organize meetings for various departments in preparation for Stark Expo. Due to limited rooms in Stark Tower, the goal is to allocate mee...read more
Determine the minimum number of conference rooms needed to schedule meetings without overlap.
Sort the meetings by start time.
Iterate through the meetings and keep track of the rooms in use.
If a meeting starts after another ends, it can reuse the same room.
If a meeting starts before another ends, a new room is needed.
Return the maximum number of rooms in use at any point.

Asked in Amazon

Q. Dice Throws Problem Statement
You are given D
dice, each having F
faces numbered from 1 to F
. The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers e...read more
The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers equals the given 'target' sum.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the number of ways to achieve each sum with the given number of dice.
Iterate through the dice and faces to calculate the number of ways to reach each sum.
Return the result modulo 10^9 + 7.
Optimize the solution to use no more than O(S) extra space by u...read more

Asked in Maersk

Q. Fourth Largest Element in the Array
Given an array consisting of integers, your task is to determine the fourth largest element in the array. If the array does not contain at least four distinct elements, retur...read more
Find the fourth largest element in an array, return -2147483648 if not enough distinct elements.
Sort the array in descending order
Return the fourth element if it exists, else return -2147483648

Asked in Bank of America

Q. Multiples of 2 and 3 Problem Statement
Ninja is engaged in a task involving divisors. He is given 'N' numbers, and his objective is to compute the sum of all numbers which are divisible by either 2 or 3.
Exampl...read more
Find the sum of numbers divisible by 2 or 3 from a given list of numbers.
Iterate through the list of numbers and check if each number is divisible by 2 or 3.
If a number is divisible by 2 or 3, add it to the sum.
Return the final sum as the output.

Asked in Avalon Information Systems

Q. Reverse String Word Wise Problem Statement
Your task is to reverse the given string word-wise. This means the last word in the string should appear first, the second last word should appear second, and so forth...read more
The given string needs to be reversed word wise, keeping the individual words intact.
Split the string into an array of words using a space as the delimiter.
Reverse the array of words.
Join the reversed array of words using a space as the separator to form the final reversed string.

Asked in MAQ Software

Q. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an array of 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of the positions of 0s, 1s, and 2s in the array.
Iterate through the array and swap elements based on the values encountered.
Maintain left pointer for 0s, right pointer for 2s, and current pointer for traversal.
Example: If current element is 0, swap it with element at left pointer and increment both pointers.

Asked in Infosys

Q. String Compression Problem Statement
Implement a program that performs basic string compression. When a character is consecutively repeated more than once, replace the consecutive duplicates with the count of r...read more
Implement a program to compress a string by replacing consecutive duplicates with the count of repetitions.
Iterate through the string and keep track of consecutive characters and their counts.
Replace consecutive duplicates with the count of repetitions.
Ensure the count of repetitions is ≤ 9.
Return the compressed string.

Asked in Goldman Sachs

Q. Count Pairs with Difference K
Given an array of integers and an integer K
, determine and print the count of all pairs in the array that have an absolute difference of K
.
Input:
The first line of the input conta...read more
Count pairs in an array with a specific absolute difference.
Iterate through the array and for each element, check if the element + K or element - K exists in the array.
Use a hash set to store elements for constant time lookups.
Keep track of the count of valid pairs found.

Asked in Sourcefuse Technologies

Q. Count Ways to Climb Stairs Problem
Given a staircase with a certain number of steps, you start at the 0th step, and your goal is to reach the Nth step. At every step, you have the option to move either one step...read more
Count the number of distinct ways to climb a staircase with a certain number of steps using either one or two steps at a time.
Use dynamic programming to solve this problem efficiently.
Keep track of the number of ways to reach each step by considering the number of ways to reach the previous two steps.
Return the result modulo 10^9+7 to handle large outputs.
Example: For N=4, the distinct ways to climb are {(0,1,2,3,4)}, {(0,1,2,4)}, {(0,2,3,4)}, {(0,1,3,4)}, and {(0,2,4)} total...read more
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

