Add office photos
Microsoft Corporation logo
Employer?
Claim Account for FREE

Microsoft Corporation

4.0
based on 1.7k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
Software Engineer
Fresher
Experienced
Skills
Clear (1)

50+ Microsoft Corporation Software Engineer Interview Questions and Answers

Updated 16 Dec 2024

Q1. You have a cuboid (m*n*p) each block of the cuboid is having a metallic ball. Now we are passing X-ray from front face and getting a bool matrix1 of m*p the elements are set if there is a black spot.(as we are...

read more
Ans.

Yes, it is possible to get the accurate result from the given data.

  • The coordinates (i,j,k) where metallic balls are present can be determined by finding the set elements in both matrix1 and matrix2.

  • Additional data is not required as the given data is sufficient to determine the coordinates.

  • The coordinates can be obtained by iterating through the elements of matrix1 and matrix2 and checking for set elements.

Add your answer
right arrow

Q2. Word Wrap Problem Statement

You are tasked with arranging 'N' words of varying lengths such that each line contains at most 'M' characters, with each word separated by a space. The challenge is to minimize the ...read more

Ans.

The goal is to minimize the total cost of arranging 'N' words on each line with a maximum character limit 'M'.

  • Calculate the cost of each line as the cube of extra space characters needed to reach 'M'.

  • Minimize the total cost by arranging words to fit within the character limit on each line.

  • Ensure each word appears fully on one line without breaking across lines.

Add your answer
right arrow
Microsoft Corporation Software Engineer Interview Questions and Answers for Freshers
illustration image

Q3. Distinct Islands Problem Statement

Given a two-dimensional array/list consisting of integers 0s and 1s, where 1 represents land and 0 represents water, determine the number of distinct islands. A group of conne...read more

Ans.

Count the number of distinct islands in a 2D array of 0s and 1s.

  • Identify islands by performing depth-first search (DFS) on the grid

  • Use a set to store the shape of each island and check for duplicates

  • Consider translations to determine distinct islands

Add your answer
right arrow
Q4. Can you design a system similar to Red Bus that can handle bookings and onboard both vendors and customers to the platform?
Ans.

Design a system similar to Red Bus for handling bookings and onboarding vendors and customers.

  • Implement a user-friendly interface for customers to search and book tickets

  • Create a vendor portal for vendors to manage their offerings and availability

  • Include payment gateway integration for secure transactions

  • Develop a robust backend system for managing bookings, cancellations, and refunds

  • Utilize a database to store user information, booking details, and vendor listings

Add your answer
right arrow
Discover Microsoft Corporation interview dos and don'ts from real experiences

Q5. Testing whether every left child's value is less than the right child's value in a binary tree

Ans.

To test if every left child's value is less than the right child's value in a binary tree.

  • Traverse the binary tree using any traversal algorithm (e.g., in-order, pre-order, post-order)

  • Compare the value of each left child with its right child

  • If any left child's value is greater than or equal to its right child's value, return false

  • If all left child's values are less than their right child's values, return true

View 1 answer
right arrow

Q6. On circular queue and finding the last number which is highest and contains same number. Of digits a the given numbber

Ans.

The question is about finding the last number in a circular queue that has the highest number of digits.

  • Implement a circular queue data structure

  • Iterate through the circular queue to find the last number with the highest number of digits

  • Compare the number of digits of each number in the circular queue

  • Keep track of the last number with the highest number of digits

Add your answer
right arrow
Are these interview questions helpful?

Q7. Write a program to store a tree on a file. Also write code to reconstruct the tree from that file. Think of efficient techniques

Ans.

Program to store and reconstruct a tree from a file with efficient techniques.

  • Use a recursive approach to traverse the tree and write each node to the file

  • Include information about the node's parent and children in the file

  • Use a unique identifier for each node to reconstruct the tree from the file

  • Use a data structure like a hash table to store the nodes and their identifiers for efficient reconstruction

Add your answer
right arrow

Q8. Given an array, find how many such pairs having sum equal to 0 are there?

Ans.

Find pairs in an array with sum equal to 0.

  • Use a hash table to store the frequency of each element.

  • Iterate through the array and for each element, check if its complement (negative value) exists in the hash table.

  • If it exists, add the frequency of the complement to the count of pairs.

  • Return the count of pairs.

  • Example: array = [2, -2, 3, 0, -3], pairs = 2 (-2, 2 and -3, 3)

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Given a string of unknown length, what is a good approach to find n-k th element from last

Ans.

To find n-k th element from last in a string of unknown length

  • Traverse the string to find its length

  • Calculate the position of n-k th element from last

  • Traverse the string again to find the element at calculated position

Add your answer
right arrow

Q10. You have a Binary tree having numbers>=0 and a numeber N. Print all downwards paths from any node having the sum of elements equal to N

Ans.

Print all downward paths from any node in a binary tree with sum of elements equal to N.

  • Traverse the binary tree and keep track of the sum of elements in the path from root to current node.

  • If the sum equals N, print the path from root to current node.

  • Recursively traverse the left and right subtrees with updated sum.

  • Use a stack to keep track of the current path being traversed.

  • Example: Binary tree with root 1, left child 2, right child 3, and N=3. Output: [1,2], [1,3].

Add your answer
right arrow

Q11. Why important in learning programming languages.

Ans.

Learning programming languages is important for software engineers to effectively communicate with computers and develop software solutions.

  • Programming languages are the foundation of software development.

  • Learning multiple languages expands the range of problems a software engineer can solve.

  • Different languages have different strengths and are suited for different tasks.

  • Knowing multiple languages improves adaptability and flexibility in the industry.

  • Programming languages evol...read more

View 2 more answers
right arrow

Q12. What do you know about Object Oriented Programming?

Ans.

Object Oriented Programming is a programming paradigm based on the concept of objects, which can contain data and code.

  • OOP focuses on creating objects that interact with each other to solve problems

  • Encapsulation, inheritance, and polymorphism are key principles of OOP

  • Examples of OOP languages include Java, C++, and Python

Add your answer
right arrow

Q13. Finding a loop in a directed graph, find the last element in a binary tree

Ans.

To find a loop in a directed graph, use Floyd's cycle-finding algorithm. To find the last element in a binary tree, traverse the tree and return the rightmost leaf node.

  • For finding a loop in a directed graph, use Floyd's cycle-finding algorithm which uses two pointers moving at different speeds.

  • To find the last element in a binary tree, traverse the tree recursively or iteratively and return the rightmost leaf node.

Add your answer
right arrow

Q14. Write the backend server code for a tic tac toe game

Ans.

Backend server code for a tic tac toe game

  • Create a RESTful API using a framework like Express.js

  • Implement game logic to check for winning conditions

  • Use a database to store game state and user information

  • Handle user authentication and authorization

  • Implement real-time updates using WebSockets

Add your answer
right arrow

Q15. Rearranging a string so no consecutive characters are the same

Ans.

Rearrange a string to avoid consecutive same characters.

  • Iterate through the string and keep track of the previous character.

  • If the current character is the same as the previous, swap it with the next different character.

  • Repeat until no consecutive same characters are left.

Add your answer
right arrow

Q16. Given an array of strings, count the number of unique occurrences

Ans.

Count the number of unique occurrences in an array of strings.

  • Create a hash table to store the count of each string occurrence.

  • Iterate through the array and update the count in the hash table.

  • Count the number of unique occurrences by counting the number of keys in the hash table.

Add your answer
right arrow

Q17. Find the shortest path in a graph between 2 given vertices.

Ans.

Use Dijkstra's algorithm to find the shortest path between 2 vertices in a graph.

  • Implement Dijkstra's algorithm to find the shortest path

  • Create a priority queue to keep track of the vertices with the shortest distance

  • Use a visited set to avoid revisiting vertices

  • Stop when the destination vertex is reached

  • Return the shortest path found

  • Example: finding the shortest path between A and D in a graph with weighted edges: A->B(1), A->C(4), B->D(3), C->D(2) returns [A, B, D]

Add your answer
right arrow

Q18. Finding the nth character in a stream of bytes

Ans.

To find the nth character in a stream of bytes, we need to read the stream byte by byte until we reach the nth position.

  • Start reading the stream byte by byte until you reach the nth position

  • Return the byte at the nth position

  • If the stream ends before reaching the nth position, return null or throw an exception

Add your answer
right arrow

Q19. Design LLD of a top K frequently purchased items in a amazon/flipkart sale

Ans.

Design a system to find top K frequently purchased items in a sale on e-commerce platforms like Amazon or Flipkart.

  • Use a data structure like a hashmap to store item frequencies

  • Implement a priority queue to keep track of top K items based on frequency

  • Update the priority queue whenever a new item is purchased

  • Consider using a heap data structure for efficient retrieval of top K items

Add your answer
right arrow

Q20. Deep copy a singly linked list with next and a random pointer

Ans.

Deep copy a singly linked list with next and a random pointer

  • Create a new node for each node in the original list

  • Copy the next and random pointers of each node to the new node

  • Use a hash table to keep track of original and new nodes

Add your answer
right arrow

Q21. Leetcode: Find centre of a linked list, follow-up: find intersection of two linked lists.

Ans.

To find the intersection of two linked lists, first find the lengths of both lists and then align the starting points before iterating to find the intersection node.

  • Find the lengths of both linked lists.

  • Align the starting points of both lists by moving the pointer of the longer list by the difference in lengths.

  • Iterate through both lists simultaneously and compare nodes to find the intersection node.

Add your answer
right arrow

Q22. Syetem Design. Design a file upload and download system

Ans.

Design a file upload and download system for efficient file management.

  • Use a cloud storage service like AWS S3 for storing files securely.

  • Implement a user-friendly interface for users to easily upload and download files.

  • Include features like file versioning, access control, and encryption for data security.

  • Consider implementing a queuing system for handling large file uploads to prevent system overload.

  • Use a content delivery network (CDN) for faster file downloads.

  • Implement m...read more

Add your answer
right arrow

Q23. What is operator nd there function?

Ans.

The '&&' operator is a logical AND operator that returns true if both operands are true, otherwise false.

  • Used to combine two boolean expressions and return true only if both are true

  • Short-circuits if the first operand is false, not evaluating the second operand

  • Example: if(x > 5 && y < 10) { // do something }

Add your answer
right arrow

Q24. Variation of aggressive cows problem (requires binary search)

Ans.

Use binary search to find the minimum distance to escape aggressive cows in a field.

  • Implement a function to check if cows can be placed with a minimum distance in a field.

  • Use binary search to find the minimum distance that satisfies the condition.

  • Keep track of the maximum distance found so far while performing binary search.

Add your answer
right arrow

Q25. Which os system used in computer ?

Ans.

There are several operating systems used in computers, including Windows, macOS, and Linux.

  • Windows is the most widely used OS for personal computers.

  • macOS is the OS used in Apple computers.

  • Linux is an open-source OS used in servers and some personal computers.

  • Other OS include Chrome OS, FreeBSD, and Solaris.

Add your answer
right arrow

Q26. What is the relation of msecxel and powerbi

Ans.

Power BI is a business analytics tool by Microsoft while Excel is a spreadsheet program. Power BI can connect to Excel files for data analysis.

  • Power BI is a business analytics tool by Microsoft

  • Excel is a spreadsheet program also by Microsoft

  • Power BI can connect to Excel files for data analysis

Add your answer
right arrow

Q27. how to scale to billions of user

Ans.

To scale to billions of users, focus on horizontal scaling, efficient database design, caching, load balancing, and microservices architecture.

  • Implement horizontal scaling by adding more servers to distribute the load.

  • Optimize database design for efficient read and write operations, consider sharding or partitioning.

  • Utilize caching mechanisms like Redis or Memcached to reduce database load.

  • Implement load balancing to evenly distribute incoming traffic across multiple servers....read more

Add your answer
right arrow

Q28. Finding the next highest palindrome

Ans.

The task is to find the next highest palindrome number given a number.

  • Convert the given number to a string

  • Check if the number is already a palindrome

  • If not, increment the number by 1 and check if it is a palindrome

  • Repeat the previous step until a palindrome is found

Add your answer
right arrow

Q29. Cloning a linked list-like structure

Ans.

Cloning a linked list-like structure

  • Create a new node for each node in the original linked list

  • Set the value of the new node to the value of the corresponding node in the original linked list

  • Set the next pointer of the new node to the new node corresponding to the next node in the original linked list

  • Repeat the above steps until all nodes in the original linked list are cloned

Add your answer
right arrow

Q30. To canonicalize a directory path

Ans.

Canonicalizing a directory path involves simplifying and standardizing the path to remove any redundant or unnecessary elements.

  • Remove any consecutive slashes and replace them with a single slash

  • Remove any trailing slashes

  • Resolve any relative paths (e.g., '..' and '.')

  • Handle special cases like the root directory ('/')

  • Normalize the path by removing any unnecessary elements

Add your answer
right arrow

Q31. Given an array find the given element in the array

Ans.

Use linear search algorithm to find the given element in the array of strings.

  • Iterate through the array and compare each element with the given element

  • Return the index if found, otherwise return -1

  • Time complexity is O(n) where n is the number of elements in the array

Add your answer
right arrow

Q32. What is algorithm? How to use?

Ans.

An algorithm is a step-by-step procedure for solving a problem or accomplishing a task.

  • An algorithm is a set of instructions that specifies a sequence of operations to be performed.

  • Algorithms can be used to solve mathematical problems, data processing tasks, and more.

  • Examples of algorithms include sorting algorithms like bubble sort and searching algorithms like binary search.

Add your answer
right arrow

Q33. What is array?nd types?

Ans.

An array is a data structure that stores a collection of elements of the same type in a contiguous memory location.

  • Arrays can be of different types such as integer arrays, float arrays, character arrays, etc.

  • An array of strings is a collection of strings stored in a contiguous memory location.

  • Example: string[] names = {"Alice", "Bob", "Charlie"};

Add your answer
right arrow

Q34. Write code for Circular Linkekd List

Ans.

Code for Circular Linked List implementation

  • Create a Node class with data and next pointer

  • Implement methods for insertion, deletion, and traversal

  • Ensure the last node points back to the first node to form a circular structure

Add your answer
right arrow

Q35. Run length encoding of a string.

Ans.

Run length encoding is a simple form of data compression where consecutive characters are replaced with a single character and a count.

  • Iterate through the input string and count consecutive characters.

  • Replace consecutive characters with a single character and a count.

  • Return the encoded string.

Add your answer
right arrow

Q36. Convert doubly linked list to BST

Ans.

Convert a doubly linked list to a binary search tree.

  • Find the middle node of the linked list.

  • Make it the root of the BST.

  • Recursively convert the left and right halves of the list to the left and right subtrees of the root.

  • Use the doubly linked list to traverse the list efficiently.

Add your answer
right arrow

Q37. Which language ur perfect

Ans.

I am proficient in multiple languages, including Java, Python, and C++.

  • Proficient in Java, Python, and C++

  • Experience with web development languages like JavaScript and HTML/CSS

  • Familiarity with scripting languages like Bash and PowerShell

Add your answer
right arrow

Q38. how to handle offline users

Ans.

Handle offline users by implementing offline mode functionality and syncing data when connection is restored.

  • Implement offline mode functionality to allow users to access certain features offline.

  • Store user data locally on the device and sync with the server when connection is available.

  • Provide feedback to users about their offline status and guide them on how to sync data.

  • Use caching mechanisms to store data temporarily and update it when connection is restored.

Add your answer
right arrow

Q39. Project explanation and run the project

Ans.

I will explain and demonstrate the project.

  • I will provide a brief overview of the project's purpose and goals.

  • I will explain the technologies and tools used in the project.

  • I will describe the project's architecture and components.

  • I will demonstrate the project by running it and showcasing its features.

  • I will answer any specific questions or concerns about the project.

Add your answer
right arrow

Q40. Leetcode: Interval merging problem

Ans.

Merge overlapping intervals in an array

  • Sort the intervals based on the start time

  • Iterate through the intervals and merge overlapping ones

  • Update the end time of the merged interval

Add your answer
right arrow

Q41. Design recommendation system for ecommerce

Ans.

Design a recommendation system for ecommerce

  • Utilize collaborative filtering to recommend products based on user behavior

  • Implement content-based filtering to suggest items similar to those previously purchased

  • Incorporate machine learning algorithms to personalize recommendations

  • Consider using a hybrid approach combining collaborative and content-based filtering

  • Include user feedback and ratings to improve recommendation accuracy

Add your answer
right arrow

Q42. Analysis about app performance

Ans.

App performance analysis involves identifying and resolving bottlenecks to improve user experience.

  • Collect and analyze performance metrics such as response time, CPU usage, memory usage, and network latency.

  • Identify and prioritize bottlenecks based on impact on user experience and frequency of occurrence.

  • Implement optimizations such as caching, code refactoring, and database tuning.

  • Continuously monitor and test performance to ensure improvements are effective.

  • Use tools such a...read more

Add your answer
right arrow

Q43. Full form of RAM and ROM?

Ans.

RAM stands for Random Access Memory and ROM stands for Read Only Memory.

  • RAM is a type of computer memory that can be accessed randomly, meaning any byte of memory can be accessed without touching the preceding bytes.

  • ROM is a type of memory that can only be read and not written to. It is used to store permanent data that cannot be changed.

  • Examples of RAM include DDR, DDR2, DDR3, and DDR4.

  • Examples of ROM include PROM, EPROM, EEPROM, and flash memory.

Add your answer
right arrow

Q44. implement serialization of tree

Ans.

Serialize a tree data structure

  • Use pre-order traversal to serialize the tree

  • Store null values as a special character

  • Use a delimiter to separate nodes

  • Example: 1,2,null,null,3,4,null,null,5,null,null

  • Deserialize by splitting the string and using a queue

Add your answer
right arrow

Q45. Number of connected components.

Ans.

Number of connected components in a graph represent the number of subgraphs that are not connected to each other.

  • Use depth-first search (DFS) or breadth-first search (BFS) to find connected components.

  • Count the number of times DFS or BFS is called to find the number of connected components.

  • Example: In a graph with 3 connected components, the answer would be 3.

Add your answer
right arrow

Q46. implement stack using linkedlist

Ans.

Implementing stack using linked list

  • Create a Node class with data and next pointer

  • Create a Stack class with top pointer

  • Implement push() method to add element to top of stack

  • Implement pop() method to remove element from top of stack

  • Implement peek() method to return top element without removing it

Add your answer
right arrow

Q47. Design phone book(Trie)

Ans.

Phone book design using Trie data structure

  • Implement Trie data structure to store phone numbers

  • Each node in the Trie represents a digit in the phone number

  • Use Trie to efficiently search for phone numbers based on prefixes

Add your answer
right arrow

Q48. Design a library management system

Ans.

A library management system to track books, users, and transactions

  • Create database tables for books, users, transactions

  • Implement functions for adding, updating, and deleting books

  • Allow users to check out and return books

  • Generate reports on book availability and user activity

Add your answer
right arrow

Q49. variation of 2 sum problem

Ans.

Find two numbers in an array that add up to a target sum.

  • Use a hash map to store the difference between the target sum and each element.

  • Iterate through the array and check if the current element's complement exists in the hash map.

  • Return the indices of the two numbers that add up to the target sum.

Add your answer
right arrow

Q50. Sort the array in alternates

Ans.

Sort the array in alternates

  • Iterate through the array and separate the strings into two separate arrays based on their index being even or odd

  • Sort both arrays separately

  • Merge the two sorted arrays back into the original array in alternate positions

Add your answer
right arrow

Q51. Design Auto completion.

Ans.

Auto completion feature suggests possible completions as user types.

  • Implement a trie data structure to store all possible words in the dictionary.

  • As user types, traverse the trie to find all words that match the prefix.

  • Display the matched words in a dropdown menu for user selection.

Add your answer
right arrow

Q52. implement priority queue

Ans.

Priority queue is a data structure that stores elements with priority levels and retrieves them in order of priority.

  • Elements are added with a priority level and retrieved in order of priority

  • Can be implemented using a heap data structure

  • Operations include insert, delete, and peek

  • Can be used in algorithms such as Dijkstra's shortest path algorithm

Add your answer
right arrow

Q53. Discuss monitoring techniques

Ans.

Monitoring techniques are essential for tracking the performance and health of software systems.

  • Use logging to record events and errors in the system

  • Implement metrics to measure key performance indicators

  • Set up alerts to notify of any abnormal behavior

  • Utilize tracing to track requests and identify bottlenecks

Add your answer
right arrow

Q54. Minimum path sum problem

Ans.

Minimum path sum problem involves finding the path with the smallest sum in a grid of numbers.

  • Start from the top left corner and move only right or down.

  • Use dynamic programming to store the minimum sum at each cell.

  • The final cell will contain the minimum path sum.

Add your answer
right arrow

Q55. design a rest API

Ans.

Design a REST API for a software engineer interview

  • Define the resources and endpoints

  • Use HTTP methods for CRUD operations (GET, POST, PUT, DELETE)

  • Implement authentication and authorization

  • Use JSON for data exchange format

  • Include error handling and status codes

Add your answer
right arrow

Q56. Turn BST into LL

Ans.

Convert a Binary Search Tree (BST) into a sorted linked list (LL)

  • Perform in-order traversal of the BST and store the nodes in a list

  • Iterate through the list and create a new linked list with the nodes in sorted order

Add your answer
right arrow

Q57. DSA qn on graphs

Ans.

Graphs are data structures that consist of nodes and edges connecting them.

  • Graphs can be directed or undirected.

  • Common graph traversal algorithms include BFS and DFS.

  • Examples of graphs include social networks, road networks, and computer networks.

Add your answer
right arrow

More about working at Microsoft Corporation

Back
Awards Leaf
AmbitionBox Logo
Top Rated Internet/Product Company - 2024
Awards Leaf
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at Microsoft Corporation Software Engineer

based on 49 interviews
5 Interview rounds
Coding Test Round
Technical Round
Aptitude Test Round
Personal Interview1 Round - 1
Personal Interview1 Round - 2
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Engineer Interview Questions from Similar Companies

Mphasis Logo
3.4
 • 25 Interview Questions
FIS Logo
3.9
 • 14 Interview Questions
Nagarro Logo
4.0
 • 14 Interview Questions
Intel Logo
4.2
 • 11 Interview Questions
UKG Logo
3.1
 • 10 Interview Questions
View all
Recently Viewed
LIST OF COMPANIES
Credit Bajaar
Overview
PHOTOS
InsuranceDekho
3 office photos
LIST OF COMPANIES
Discover companies
Find best workplace
INTERVIEWS
UltraTech Cement
No Interviews
INTERVIEWS
Microsoft Corporation
5.6k top interview questions
SALARIES
Automatic Data Processing (ADP)
INTERVIEWS
UltraTech Cement
No Interviews
INTERVIEWS
Sutherland Global Services
No Interviews
INTERVIEWS
Sutherland Global Services
No Interviews
SALARIES
Automatic Data Processing (ADP)
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter