Microsoft Corporation
10+ Interview Questions and Answers
Q1. Reverse the order of words in a given sentence(an array of characters)
To reverse the order of words in a given sentence, we need to split the sentence into words and then reverse the order of the resulting array.
Split the sentence into words using a delimiter like space or comma
Reverse the resulting array of words
Join the reversed array of words using a delimiter to form the reversed sentence
Q2. How are you fetching data through api in your project.And how machine learning is working in your project
Data is fetched through RESTful APIs using Python requests library. Machine learning is used for predictive analysis.
API data is retrieved using HTTP GET requests
Python requests library is used to handle API requests and responses
Data is parsed using JSON library
Machine learning models are trained on historical data to predict future outcomes
Scikit-learn library is used for machine learning tasks
Q3. Given N people of an M*M grid, find the point that requires the least total distance by all people to meet at that point.
Given N people on an M*M grid, find the point with the least total distance for all to meet.
Calculate the Manhattan distance for each point on the grid
Find the point with the minimum total distance
Use dynamic programming to optimize the solution
Consider edge cases such as when N=1 or M=1
Q4. remove duplicates in unsorted linked list
Remove duplicates in unsorted linked list
Create a hash table to keep track of visited nodes
Traverse the linked list and check if the node is already visited
If visited, remove the node from the linked list
Time complexity: O(n)
Example: 1 -> 2 -> 3 -> 2 -> 4 -> 1 -> null
Output: 1 -> 2 -> 3 -> 4 -> null
Q5. Number of islands problem
The number of islands problem involves counting the number of connected islands in a grid.
An island is a group of connected 1s in a grid of 0s and 1s.
Use depth-first search or breadth-first search to traverse the grid and count the islands.
Keep track of visited cells to avoid counting the same island multiple times.
Q6. find intersection point of two linked list
Find intersection point of two linked lists.
Traverse both lists and find their lengths
Move the head of the longer list by the difference in lengths
Traverse both lists in parallel until they meet at the intersection point
Q7. Given a target and a binary tree, return true if there is a path to target
Check if there is a path in a binary tree to a given target
Start from the root node and traverse the tree using depth-first search (DFS)
Keep track of the current path sum and compare it with the target value
Return true if a path with the target sum is found, otherwise return false
Q8. Scope resolution program
Scope resolution program is used to determine the scope of a variable in a program.
It helps in identifying the location of a variable in a program
It helps in avoiding naming conflicts between variables
It can be done using the dot operator or the arrow operator in object-oriented programming
It can also be done using the scope resolution operator (::) in C++
Q9. Delete a node from Singly and doubly linked list
To delete a node from a singly or doubly linked list, update the pointers of the previous and next nodes.
For a singly linked list, update the next pointer of the previous node to skip the node to be deleted.
For a doubly linked list, update the next pointer of the previous node and the previous pointer of the next node to skip the node to be deleted.
Q10. find the depth of the tree
The depth of a tree is the length of the longest path from the root node to a leaf node.
The depth of a tree can be calculated by traversing the tree and keeping track of the depth at each node.
The depth of a tree with only one node (the root) is 0.
For example, in a binary tree, the depth of the tree is the maximum depth of the left and right subtrees plus 1.
Q11. validate an email using regex pattern
Use regex pattern to validate an email address
Use regex pattern /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
Ensure email has valid format with username, @ symbol, domain, and top-level domain
Test regex pattern against different email addresses for validation
Q12. BFS implementation on a tree
BFS (Breadth First Search) is a traversal algorithm used to visit all nodes of a tree level by level.
Start by visiting the root node, then visit all its children before moving on to the next level
Use a queue data structure to keep track of nodes to visit next
Repeat the process until all nodes have been visited
Q13. Two sum Water tank problem
Two sum problem involves finding two numbers in an array that add up to a specific target. Water tank problem involves calculating the amount of water that can be trapped between the bars.
For Two sum problem, use a hashmap to store the difference between the target and each element in the array. Check if the current element exists in the hashmap.
For Water tank problem, use two pointers approach to calculate the maximum water that can be trapped between the bars.
Example for Tw...read more
Q14. Square root of N
The square root of a number N is a value that, when multiplied by itself, gives N.
The square root of 9 is 3, because 3 * 3 = 9
The square root of 16 is 4, because 4 * 4 = 16
The square root of 25 is 5, because 5 * 5 = 25
Q15. project on ai-ml
AI-ML project involves using artificial intelligence and machine learning algorithms to analyze data and make predictions.
Collecting and cleaning data for training the AI model
Choosing the appropriate machine learning algorithm for the task
Evaluating the performance of the model using metrics like accuracy and precision
Implementing the model in a real-world application
Continuously improving the model through feedback and retraining
More about working at Microsoft Corporation
Top HR Questions asked in null
Interview Process at null
Top Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month