Software Developer
7000+ Software Developer Interview Questions and Answers
Popular Companies
Q1. 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
Q2. 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
Software Developer Interview Questions and Answers for Freshers
Q3. 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
Q4. 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
Q5. 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
Q6. Find Duplicate in Array Problem Statement
You are provided with an array of integers 'ARR' consisting of 'N' elements. Each integer is within the range [1, N-1], and the array contains exactly one duplicated el...read more
The task is to find the duplicate element in an array of integers.
Iterate through the array and keep track of the frequency of each element using a hash map.
Return the element with a frequency greater than 1.
Alternatively, sort the array and check for adjacent elements with the same value.
Share interview questions and help millions of jobseekers 🌟
Q7. 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
Q8. 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
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
Software Developer Jobs
Q9. 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
Q10. 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
Q11. 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
Q12. 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
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
Q13. 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
Q14. 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
Q15. Triangle of Numbers Pattern
Ninja is tasked with printing a triangle pattern based on a given number 'N' for any test case.
Example:
Input:
N = 4
Output:
1
232
34545
4567654
Explanation:
The pattern comprises n...read more
Q16. 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
Q17. 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
Q18. Maximum Coins Collection Problem
Imagine a two-dimensional grid with 'N' rows and 'M' columns, where each cell contains a certain number of coins. Alice and Bob want to maximize the total number of coins they c...read more
Given a matrix of coins, Alice and Bob have to collect maximum coins with certain conditions.
Alice starts from top left corner and Bob starts from top right corner
They can move to (i+1, j+1) or (i+1, j-1) or (i+1, j)
They have to collect all the coins that are present at a cell
If Alice has already collected coins of a cell, then Bob gets no coins if goes through that cell again
Q19. 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
Q20. 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
Q21. Permutation in String Problem Statement
Determine if the string str2
contains a permutation of the string str1
as one of its substrings.
Input:
The first line contains an integer 'T', representing the number of...read more
Q22. Rearrange Array: Move Negative Numbers to the Beginning
Given an array ARR
consisting of N
integers, rearrange the elements such that all negative numbers are located before all positive numbers. The order of e...read more
Q23. 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
Q24. 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
Q25. Square Root (Integral) Problem Statement
Given a number N
, calculate its square root and output the integer part only.
Example:
Input:
18
Output:
4
Explanation:
The square root of 18 is approximately 4.24. The ...read more
Q26. Reverse Linked List Problem Statement
Given a singly linked list of integers, return the head of the reversed linked list.
Example:
Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Q27. 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
Q28. Structurally Unique Binary Trees of Dragon Balls
Goku has ‘N’ Dragon Balls, where each Dragon Ball is unique. The ith Dragon Ball has ‘i’ stars on it, meaning the first Dragon Ball has 1 star, the second has 2 ...read more
Q29. 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
Q30. 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
Q31. 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
Q32. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
Q33. 1. what is the difference between exception and error. How did u solve the errors in the code deployment?
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
Q34. Arithmetic Subarrays Problem Statement
You are provided with an array A
of length N
. Your task is to determine the number of arithmetic subarrays present within the array A
.
Explanation:
An arithmetic subarray ...read more
Count the number of arithmetic subarrays in an array.
An arithmetic subarray has 3 or more elements with the same difference between consecutive elements.
Loop through the array and check for all possible subarrays with 3 or more elements.
If the difference between consecutive elements is the same, increment the count.
Return the count for each test case.
Q35. 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.
Q36. Count Good Subsets Problem Statement
Given an array ARR
of size N
consisting of distinct elements, your task is to determine the total number of good subsets. A subset is considered a good subset if the element...read more
Q37. 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
Q38. 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
Q39. Sort Big List Dates Problem Statement
Mary is an enthusiastic party-goer who struggles with remembering event dates. Help Mary by sorting a given list of event dates in an ascending order.
Example:
Input:
dates...read more
Q40. Biggest Number Formation Problem
Your task is to construct the largest number possible by concatenating each of the provided positive integers in the array exactly once.
Input:
Integer T denoting the number of ...read more
Q41. Cycle Detection in a Singly Linked List
Determine if a given singly linked list of integers forms a cycle or not.
A cycle in a linked list occurs when a node's next
points back to a previous node in the list. T...read more
The task is to determine if a given singly linked list forms a cycle or not.
A cycle occurs when a node's next points back to a previous node in the list.
To solve this problem, we can use the Floyd's Cycle-Finding Algorithm.
The algorithm uses two pointers, one moving at a normal pace and the other moving twice as fast.
If there is a cycle, the fast pointer will eventually catch up to the slow pointer.
If the fast pointer reaches the end of the list (i.e., it encounters a null no...read more
Q42. 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
Q43. Linear Search Problem Statement
Given a random integer array/list ARR
of size N
, and an integer X
, you are required to search for the integer X
in the given array/list using Linear Search.
Return the index at w...read more
Q44. Maximum Equal Elements After K Operations
You are provided with an array/list of integers named 'ARR' of size 'N' and an integer 'K'. Your task is to determine the maximum number of elements that can be made eq...read more
Q45. 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
Q46. Painter's Partition Problem Statement
Given an array/list representing boards, where each element denotes the length of a board, and a number ‘K’ of available painters, determine the minimum time required to pa...read more
Q47. Rahul And Minimum Subarray Problem Statement
Rahul is mastering arrays. He is tasked to find the length of the smallest contiguous subarray in a given array/list ARR
of size N
, such that its sum exceeds a speci...read more
Q48. Beautiful String Problem Statement
Given a binary string STR
containing either '0' or '1', determine the minimum number of operations needed to make it beautiful. A binary string is called beautiful if it conta...read more
Q49. Chocolate Pickup Problem
Ninja has a 'GRID' of size 'R' x 'C'. Each cell of the grid contains some chocolates. Ninja has two friends, Alice and Bob, and he wants to collect as many chocolates as possible with t...read more
Q50. 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
Interview Questions of Similar Designations
Top Interview Questions for Software Developer Related Skills
Interview experiences of popular companies
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/Month