Microsoft Corporation
Glic Tech Interview Questions and Answers
Q1. Given a 2 dim array, find an element which is the maximum in its column and minimum in its row. You are assured that atleast one such element exists. You may return any one if multiple such elements exist. Writ...
read moreFind element in 2D array which is max in column and min in row with minimum comparisons
Iterate over rows and columns to find max and min elements respectively
Compare the max element of a column with the min element of its row
Return the element if it satisfies the condition
Consider edge cases like multiple elements satisfying the condition
Q2. Design an elevator system, where there are 5 elevators and 50 floors. What would be the design considerations on which elevator should come when a button is pressed on a given floor?
Design considerations for an elevator system with 5 elevators and 50 floors.
Traffic patterns and peak hours should be analyzed to determine the optimal number of elevators to be in operation at any given time.
Elevators should be programmed to prioritize stops based on the direction of travel and the proximity of the requested floor to the elevator's current location.
The system should be designed to minimize wait times and maximize efficiency.
Safety features such as emergency ...read more
Q3. Given a binary tree (not necessarily complete), connect a node to the node to its right (at the same level). Assume you have an extra pointer in the node to perform the connection
Connect nodes to their right in a binary tree using an extra pointer.
Traverse the tree using level order traversal
For each node, connect its right child to the next node in the level
If there is no next node, set the right child to null
Q4. Given an array, find if it contains a majority element. An element is a majority element if it occurs more than 50% of times. Do it in O(n)
Find if an array has a majority element in O(n)
Iterate through the array and keep track of the count of each element
If the count of any element is greater than half the length of the array, return true
Otherwise, return false
Q5. Given two linked lists, find if they have a common node
Given two linked lists, check if they have a common node.
Traverse both lists and compare each node's memory address
Use a hash table to store memory addresses of nodes in one list and check for matches in the other list
If one list is shorter, traverse it first and then start traversing the longer list from the difference in length
Q6. Given an array of numbers, return the same array containing only unique elements in the array
Return an array with only unique elements
Use a Set to store unique elements
Loop through the array and add each element to the Set
Convert the Set back to an array and return it
More about working at Microsoft Corporation
Reviews
Interviews
Salaries
Users/Month