Software Development Engineer
300+ Software Development Engineer Interview Questions and Answers
Q1. Given an acyclic graph of a city where each edge represents a road in the city and each vertex represents an crossing. Write an algo to find out the minimum number of vertices at which a policemen will be kept ...
read moreFind minimum vertices to place policemen in an acyclic graph of a city to cover all roads.
Use Depth First Search (DFS) to traverse the graph
Maintain a set of visited vertices to avoid revisiting
For each unvisited vertex, place a policeman and mark all connected edges as covered
Repeat until all edges are covered
Return the minimum number of policemen placed
Q2. You have application which shows list of all contacts, the Name can be duplicated, also it can contain duplicated numbers (0XXXXX, XXXXX etc). How will you go on and do searching in this. Search term can either...
read moreTo search for contacts with duplicate names and numbers, create a search function that checks both fields.
Create a function that takes a search term as input
Iterate through the list of contacts
Check if the search term exists in the Name field or Num field
Return the contacts that match the search term
Software Development Engineer Interview Questions and Answers for Freshers
Q3. Given a m * n matrix filled with '0's and 'x's at random position with two positions marked as start 'S' and end 'E'. From each cell you can only move to those adjacent cells that have a '0'. Moves allowed is l...
read moreFind shortest path between 'S' and 'E' in a matrix filled with '0's and 'x's
Use Breadth First Search (BFS) algorithm to find shortest path
Create a visited matrix to keep track of visited cells
Create a queue to store cells to be visited
Start BFS from 'S' and keep track of distance to each cell
When 'E' is found, return the distance to it
Q4. puzzle-There are 1000 wine bottles. One of the bottles contains poisoned wine. A rat dies after one hour of drinking the poisoned wine. How many minimum rats are needed to figure out which bottle contains poiso...
read moreAt least 10 rats are needed to figure out which bottle contains poison in an hour.
Number the bottles from 1 to 1000.
Use binary representation of the bottle numbers to assign each rat a unique combination of bottles to drink.
For example, Rat 1 drinks from all bottles with a binary representation that has a 1 in the least significant bit (LSB).
After an hour, the rats that die will indicate the binary representation of the poisoned bottle.
By decoding the binary representation, t...read more
Q5. Have you worked on cloud technology? Architecture of cloud
Yes, I have worked on cloud technology and have knowledge of cloud architecture.
I have experience working with cloud platforms such as Amazon Web Services (AWS) and Microsoft Azure.
I have designed and implemented scalable and highly available cloud-based solutions.
I am familiar with cloud architecture patterns like microservices, serverless computing, and containerization.
I have utilized cloud services like Amazon S3 for storage, AWS Lambda for serverless computing, and AWS E...read more
Q6. Given a String, find out all the permutation of the strings? Time complexity? Handle duplicate characters. AAA should only give AAA. Write Code
Find all permutations of a given string, handling duplicates.
Use recursion to generate all possible permutations
Use a hash set to keep track of already generated permutations
Handle duplicates by skipping already generated permutations
Time complexity is O(n!)
Return an array of strings containing all permutations
Share interview questions and help millions of jobseekers 🌟
Q7. You have to design screen in which at a time on screen 10 nearest restaurants will be shown in a list. How will you go on design this. (Need to keep UI as un interrupted as possible).
Design a screen to show 10 nearest restaurants in a list while keeping the UI uninterrupted.
Use a scrollable list view to display the restaurants
Implement a location-based search algorithm to find the nearest restaurants
Include a search bar to allow users to search for specific restaurants
Display relevant information for each restaurant such as name, rating, and distance
Implement filters or sorting options to allow users to customize the list
Consider using a map view to show ...read more
Q8. Given two string a and b. FInd out the minimum length substring k of a such that k contains all the characters of b. Minimum window problem
Find minimum length substring of string a containing all characters of string b.
Use sliding window approach
Maintain a frequency map of characters in b
Move the window until all characters of b are present
Update the minimum length substring as you move the window
Software Development Engineer Jobs
Q9. Pre-process a dictionary in a way that later on given a string in the dictionary, output all the strings in the dictionary that are anagrams to the given string.Data structure used. Time and space complexity
Pre-process a dictionary to output anagrams of a given string. Data structure, time and space complexity?
Create a hash table with sorted string as key and list of anagrams as value
Iterate through dictionary and sort each string, add to hash table
To find anagrams of given string, sort it and look up in hash table
Time complexity: O(n * klogk), space complexity: O(n)
n = number of strings in dictionary, k = length of longest string
Q10. you have a sorted array in increasing order.Now shift n elements from right to first. Write a code to efficiently find n(no. of elements shifted). For example: initial array : 1,2,3,7,7,7,8 after shift array : ...
read moreFind the number of elements shifted in a sorted array after shifting n elements from right to first.
Find the index of the minimum element in the shifted array
The number of elements shifted is equal to the index of the minimum element
Use binary search to find the minimum element in O(log n) time
Q11. A complete binary is defected because it has a level at which difference between heights of left and right subtree is more than 1. Find the first such level from top.
Find the first level in a complete binary tree where the height difference between left and right subtrees is more than 1.
Traverse the binary tree level by level using breadth-first search
For each level, calculate the height difference between the left and right subtrees
Return the level number when the height difference is more than 1
Q12. Given an array, which consist of natural numbers only. The elements are in random order, tell the first missing natural number in the array. e.g 4,6,3,1,6,8 o.p - 2 1,2,3 O/P - 4
Given an array of natural numbers, find the first missing natural number.
Sort the array and iterate through it to find the first missing number.
Use a hash set to keep track of the numbers present in the array.
The first missing number will be the smallest positive integer not present in the array.
Q13. Given an Object 'Ball'. How will you transfer this ball object from one thread to another in Android.
To transfer the Ball object from one thread to another in Android, we can use Handler or AsyncTask.
Use Handler to post the Ball object from one thread to another
Create a Handler in the receiving thread and use its post() method to receive the Ball object
Alternatively, use AsyncTask to perform the transfer in the background thread and update the UI thread with the Ball object
Q14. If you were asked to make your own HashMap, how will you do it. (As it was used in the first question)
A HashMap is a data structure that stores key-value pairs and provides constant time complexity for basic operations.
Implement a hash function to convert keys into array indices
Create an array to store the key-value pairs
Handle collisions using a technique like chaining or open addressing
Implement methods like put(), get(), and remove() to interact with the HashMap
Q15. Given two words, find the similarity between them. You have to develop your own sense of similarity here. Normalize length of LCS by the total length of the string.
The question asks to find the similarity between two words by normalizing the length of the longest common subsequence (LCS) by the total length of the string.
Implement a function that takes two words as input
Find the length of the longest common subsequence (LCS) between the two words
Normalize the length of LCS by dividing it by the total length of the string
Return the normalized similarity value
Q16. Different stages of a designing a new client requirement. How we design and decide on the technologies. Define the process
Design process for new client requirements and technology decisions
Gather requirements from client
Analyze requirements and identify potential solutions
Evaluate technologies and choose the best fit
Create a design document outlining the solution
Develop a prototype or proof of concept
Test and refine the solution
Implement and deploy the solution
Provide ongoing support and maintenance
Q17. Given a BST, prove that its in-order traversal is always sorted and Given a binary tree, if its in-order traversal is sorted proof that it is a BST
Prove that in-order traversal of a BST is always sorted and vice versa
In-order traversal of a BST visits nodes in ascending order
If a binary tree's in-order traversal is sorted, it is a BST
A BST's left subtree contains only nodes with values less than its root
A BST's right subtree contains only nodes with values greater than its root
Q18. How would you find least common ancestor of two nodes in a binary tree?
To find least common ancestor of two nodes in a binary tree, traverse the tree from root to the nodes and store the paths. Then compare the paths to find the common ancestor.
Traverse the binary tree from root to the two nodes and store the paths
Compare the paths to find the common ancestor
If the binary tree is a BST, compare the values of the nodes to find the common ancestor
If one of the nodes is the ancestor of the other, return the ancestor node
Q19. Implement the "People you may know" feature of facebook with code. Use BFS and counter (for mutual friends).
Implement Facebook's 'People you may know' feature using BFS and mutual friend counter.
Create a graph of users and their friends
Perform BFS on the graph starting from the user in question
For each friend of the user, increment a counter for their mutual friends
Sort the list of potential friends by mutual friend count
Exclude already connected friends and suggest top potential friends
Q20. 4. What is normalization? Explain 2NF, 3NF, BCNF. (I didn’t know BCNF).
Normalization is the process of organizing data in a database to reduce redundancy and dependency.
2NF eliminates partial dependencies by ensuring that non-key attributes depend on the entire primary key.
3NF eliminates transitive dependencies by ensuring that non-key attributes depend only on the primary key.
BCNF eliminates overlapping candidate keys by ensuring that each determinant is a candidate key.
Q21. Given an sorted array and an number n. Find out an element k in the array such that Max(k) < n. Write Code
Find an element k in a sorted array such that Max(k) < n.
Use binary search to find the largest element smaller than n
Start with mid element and adjust search range based on comparison with n
Return -1 if no such element exists
Q22. What are the backend and front end technologies used
The backend technologies used are Java, Spring Boot, and MySQL. The front end technologies used are Angular and TypeScript.
Backend: Java
Backend Framework: Spring Boot
Database: MySQL
Frontend: Angular
Frontend Language: TypeScript
Q23. How would you identify two nodes that have been swapped in a binary search tree?
To identify swapped nodes in a binary search tree, we need to perform an inorder traversal and compare adjacent nodes.
Perform an inorder traversal of the binary search tree
Compare each node with its adjacent node
If a node is smaller than its previous node, mark it as a swapped node
If two nodes are swapped, swap their values to restore the original binary search tree
Q24. What are indexes, clustered and non-clustered indexes?
Indexes are used to improve database performance by allowing faster data retrieval. Clustered indexes determine the physical order of data, while non-clustered indexes are separate structures.
Indexes are used to speed up data retrieval in databases
Clustered indexes determine the physical order of data in a table
Non-clustered indexes are separate structures that point to the data in a table
A table can have only one clustered index, but multiple non-clustered indexes
Indexes can...read more
Q25. Given a binary tree, return doubly linked list of all the nodes at each level.
The function takes a binary tree as input and returns a doubly linked list of all the nodes at each level.
Use a breadth-first search (BFS) algorithm to traverse the binary tree level by level.
For each level, create a doubly linked list and add the nodes to it.
Connect the doubly linked lists of each level to form the final result.
Q26. Longest Palindromic Substring - DP (GFG Link: -----/). Shortest path in Binary Maze - BFS (GFG Link: -----/) Check if given push and pop sequences of stack is valid or not (GFG Link: -----/)
Interview question for Software Development Engineer position on Longest Palindromic Substring, Shortest path in Binary Maze, and Valid Stack Sequences.
Longest Palindromic Substring - use dynamic programming to solve
Shortest path in Binary Maze - use BFS algorithm to find the shortest path
Valid Stack Sequences - simulate the stack push and pop operations to check if the given sequences are valid
Q27. 5) Find out the heavier ball from 8 identical ball of which one is heavier using only a balance weighting machine in least number of trys
Find the heavier ball from 8 identical balls using a balance weighting machine in least number of tries.
Divide the balls into 3 groups of 3, 3, and 2 balls.
Weigh the first two groups against each other.
If they balance, the heavier ball is in the remaining group of 2 balls.
If one group is heavier, weigh two balls from that group against each other.
If they balance, the heavier ball is the remaining ball.
If one ball is heavier, that is the heavier ball.
Q28. What is the difference between GET, POST,PUT and PATCH request ?
GET is used to request data from a specified resource, POST is used to submit data to be processed to a specified resource, PUT is used to update a resource, and PATCH is used to partially update a resource.
GET requests data from a specified resource without changing it
POST submits data to be processed to a specified resource
PUT updates a resource with the data provided
PATCH partially updates a resource with the data provided
Q29. Given an array now we can do 2 operations, idx+arr[idx] and idx-arr[idx]. Identify that can we reach to index having 0 as value.
Yes, we can use Breadth First Search (BFS) algorithm to determine if we can reach index 0 with the given operations.
Use BFS algorithm to explore all possible paths starting from index 0.
Keep track of visited indices to avoid infinite loops.
If we reach an index with value 0, return true; otherwise, return false.
Q30. Detect a loop in a linked list and return the node where the loop starts.
Detect loop in linked list and return node where loop starts.
Use two pointers, one moving one node at a time and the other moving two nodes at a time
If there is a loop, the two pointers will eventually meet at a node inside the loop
Reset one of the pointers to the head of the linked list and move both pointers one node at a time
The node where the two pointers meet is the start of the loop
Q31. what is another approach to iterate row by row instead of cursor?
An alternative to using a cursor to iterate row by row is to use a WHILE loop.
Use a WHILE loop to iterate through rows
Use a variable to keep track of the current row
Exit the loop when there are no more rows to iterate through
Q32. Write code for designing the ADT (Abstract Data Type) for all the classes that might be required to represent the game of chess
Design ADT for chess game classes
Create classes for pieces (king, queen, etc.), board, player, game
Use inheritance to represent different types of pieces
Implement methods for moving pieces, checking for checkmate, etc.
Q33. Given a m * n matrix and value k. Find k * k matrix within the given matrix whose sum is maximum
Given a matrix and value k, find k*k submatrix with maximum sum.
Iterate over all submatrices of size k*k and calculate their sum.
Keep track of the maximum sum and the corresponding submatrix.
Use dynamic programming to optimize the solution.
Time complexity can be reduced to O(m*n*k^2) using prefix sum technique.
Q34. How would you optimize it for a binary search tree?
Optimizing for binary search tree
Ensure the tree is balanced to maintain O(log n) search time
Implement efficient insertion and deletion algorithms
Use in-order traversal for sorted output
Consider using AVL or Red-Black trees for self-balancing
Avoid using recursion for large trees to prevent stack overflow
Q35. Find shortest path to reach from one point to another in a 2d matrix. Link - -----/
Shortest path in 2D matrix
Use BFS or Dijkstra's algorithm
Create a visited matrix to avoid revisiting cells
Keep track of distance and path
Consider obstacles or blocked cells
Q36. in an integer array where element represent stock price and index represent days how to detect the best day to buy and best day to sell in O(N)
To detect the best day to buy and sell stock in an integer array representing stock prices and days in O(N).
Iterate through the array and keep track of the minimum price seen so far.
Calculate the profit by subtracting the current price from the minimum price.
Update the maximum profit and best buy/sell days accordingly.
Return the best buy and sell days to maximize profit.
Q37. what is multiingule ? what is extension of file used for it ?
Multiingule is not a known term. No extension is used for it.
Multiingule is not a recognized term in software development.
There is no file extension associated with multiingule.
It is possible that the interviewer misspoke or meant to ask a different question.
Q38. what is user control ? what is extension of user control ?
User control is a reusable UI component that allows users to interact with an application. An extension of user control is a custom control that inherits from the user control.
User control is a UI component that can be reused across an application
It allows users to interact with an application
An extension of user control is a custom control that inherits from the user control
Custom controls can be created by adding additional functionality to the base user control
Examples of ...read more
Q39. Write code for the subtitle syncing application you talked about, not the entire thing, just the crux of it.
Code for subtitle syncing application
Create a function to parse subtitle file and extract time stamps
Create a function to parse video file and extract time stamps
Calculate time difference between subtitle and video time stamps
Adjust subtitle time stamps accordingly
Output synced subtitle file
Q40. 2. Print first 200 Fibonacci numbers in reverse order. (I did it but it was not efficient).
Print first 200 Fibonacci numbers in reverse order.
Use an array to store the Fibonacci numbers
Start with 0 and 1, then add the previous two numbers to get the next one
Loop through the array in reverse order to print the numbers
Q41. Given a binary tree, check whether it is a BST or not.Write the algo. Time and space complexity
Check if a binary tree is a BST or not and give time and space complexity.
Traverse the tree in-order and check if the elements are in ascending order
Keep track of the maximum value seen so far while traversing
If any element violates the ascending order, return false
Time complexity: O(n), Space complexity: O(h) where h is the height of the tree
Q42. Given a sorted array that contains 0s and 1s. find out the first occurrence of 1. Write Code
Find the first occurrence of 1 in a sorted array of 0s and 1s.
Use binary search to find the first occurrence of 1.
If mid element is 1, check left subarray for first occurrence.
If mid element is 0, check right subarray for first occurrence.
Q43. Given an array containing 0s,1s,2s. Sort the array without using counting sort. Write Code
Sort an array of 0s, 1s, and 2s without using counting sort.
Use three pointers to keep track of the positions of 0s, 1s, and 2s.
Traverse the array and swap elements to their respective positions.
Time complexity: O(n), Space complexity: O(1).
Q44. Given a string of bracket, now identify number of flips require to balance parenthesis
Count number of flips required to balance parentheses in a string
Iterate through the string and keep track of open and close brackets
If a close bracket is encountered without a corresponding open bracket, increment flip count
Return the total number of flips required to balance the parentheses
Q45. Maximum absolute difference between any two level's sum in a binary tree
Calculate the maximum absolute difference between the sums of any two levels in a binary tree.
Traverse the binary tree level by level and calculate the sum of nodes at each level.
Keep track of the maximum absolute difference between the sums of any two levels encountered so far.
Return the maximum absolute difference found.
Q46. Separate prime from non prime in array if order doesn't matter
Use a hashmap to separate prime and non-prime numbers in an array of strings.
Iterate through the array and convert each string to an integer.
Use a hashmap to store prime and non-prime numbers based on their divisibility.
Convert the hashmap back to separate arrays for prime and non-prime numbers.
Q47. Separate prime from non prime in linked list , by preserving there order
Separate prime numbers from non-prime numbers in a linked list while preserving their order.
Iterate through the linked list and separate prime numbers from non-prime numbers
Create two separate linked lists for prime and non-prime numbers
Maintain the order of numbers while separating them
Example: Input: 1 -> 2 -> 3 -> 4 -> 5, Output: Prime: 2 -> 3 -> 5, Non-prime: 1 -> 4
Q48. Given an array of integers such that the adjacent elements are either 1+ or 1- from each other. Example : 1,2,3,2,3,4 Suggest an efficient way to search a given element
Efficient way to search a given element in an array of integers with adjacent elements 1+ or 1- from each other.
Use binary search algorithm to search the element in O(log n) time complexity.
Check the middle element and compare it with the given element.
If the middle element is greater than the given element, search in the left half of the array.
If the middle element is smaller than the given element, search in the right half of the array.
Repeat until the element is found or t...read more
Q49. You are given a thread and you are unlocked in a room.Measure the height of the room using string.
Measure the height of a room using a thread.
Tie one end of the thread to a known height point, such as a door handle.
Hold the other end of the thread and let it hang down to the floor.
Mark the point where the thread touches the floor.
Repeat the process at different points in the room to get multiple measurements.
Take the average of the measurements to estimate the height of the room.
Q50. 1 - where is bean annotation used in springboot ?... In class or method
Bean annotation is used in Spring Boot on class or method to indicate that a method produces a bean to be managed by the Spring container.
Bean annotation is used on methods within a class to indicate that the method produces a bean to be managed by the Spring container.
It can also be used at the class level to indicate that the class itself is a Spring bean.
For example, @Bean annotation can be used on a method that creates and returns a DataSource bean in a configuration clas...read more
Interview Questions of Similar Designations
Top Interview Questions for Software Development Engineer 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