Microsoft Corporation
100+ Eskag Pharma Interview Questions and Answers
Q101. How will you avoid race condition on shared memory?
Use synchronization techniques like locks, semaphores, or mutexes to prevent multiple processes from accessing shared memory simultaneously.
Implementing a locking mechanism to ensure only one process can access the shared memory at a time.
Using semaphores to control access to the shared memory.
Using mutexes to ensure mutual exclusion and prevent race conditions.
Using atomic operations to ensure that memory operations are indivisible.
Using message passing instead of shared mem...read more
Q102. If you have design offline browser and what will be challenges that you will face
Designing an offline browser poses challenges such as data storage, synchronization, and user experience.
Ensuring efficient data storage and retrieval
Implementing synchronization with online content
Providing a seamless user experience with limited connectivity
Handling updates and changes to online content
Managing cache and memory usage
Dealing with security concerns
Handling different file types and formats
Q103. Given 5 points in a plane, prove that there will be atleast two points such that their midpoint is an integer
Prove that given 5 points in a plane, there will be at least two points such that their midpoint is an integer.
Consider the x and y coordinates of the 5 points.
If any two points have the same x and y coordinates, their midpoint will be an integer.
If not, consider the differences between the x and y coordinates of each pair of points.
If any two pairs have differences that are both even or both odd, their midpoints will be integers.
By the Pigeonhole Principle, there must be at ...read more
Q104. You are given binary tree. Weight of node in binary tree=data present in it*level of that node(root’s level was given to be 1).Find the node in tree with maximum weight
Find node with maximum weight in a binary tree based on data and level of node
Calculate weight of each node based on data and level
Traverse the binary tree and keep track of node with maximum weight
Return the node with maximum weight
Q105. Given three sides of a triangle, find whether a triangle is right angled, isosceles, equilateral, scalene in nature
Given three sides of a triangle, determine its nature.
Check if any two sides are equal to determine if it's isosceles
Check if all three sides are equal to determine if it's equilateral
Use Pythagoras theorem to check if it's right angled
If none of the above, it's a scalene triangle
Q106. Insert an element into a sorted circular linked list. (Consider all cases, inserting in the beginning, end and middle)
Insert an element into a sorted circular linked list.
Find the correct position to insert the element based on its value
Update the pointers of the previous and next nodes to include the new node
Handle special cases such as inserting at the beginning or end of the list
Example: Inserting 5 into a list with values 1, 3, 4, 6, 7 would result in 1, 3, 4, 5, 6, 7
Q107. Given a node in a binary tree, find the leftmost node in the same level. I wrote the pseudocode, and testcases
Find the leftmost node in the same level as a given node in a binary tree.
Traverse the tree level by level using BFS
For each level, keep track of the leftmost node encountered
Return the leftmost node at the same level as the given node
Q108. Given a set of courses along with the prerequisite courses for these courses, write a program to find the minimum number of semesters required to wrap up all the courses
Program to find minimum semesters required to complete courses with prerequisites
Create a graph with courses as nodes and prerequisites as edges
Use topological sorting to find the order of courses to be taken
Calculate the minimum number of semesters based on the order obtained
Handle cases where there are cycles in the graph
Q109. Given a string INPUT, find the longest repeating substring
Find the longest repeating substring in a given string.
Create an array of all possible substrings of the given string.
Sort the array in lexicographic order.
Find the longest common prefix between adjacent strings.
Return the longest common prefix found.
If no repeating substring is found, return an empty string.
Count total palindromic substrings in a given string.
Iterate through each character in the string and consider it as the center of a palindrome. Expand outwards to find all palindromic substrings.
Use dynamic programming to efficiently check if a substring is a palindrome.
Consider both odd-length and even-length palindromes.
Example: Input 'ababa', output 7 (a, b, a, b, a, aba, aba)
Q111. WAP to check if the binary tree is height-balanced and write testcases
WAP to check if binary tree is height-balanced and write testcases
A binary tree is height-balanced if the difference between the heights of its left and right subtrees is not more than 1
Use recursion to check if each subtree is height-balanced
Write testcases to cover all possible scenarios, including empty tree, single node tree, and unbalanced trees
Q112. Give the data structure to represent N-ary tree and write to code for its BFS
Data structure and code for BFS of N-ary tree
N-ary tree can be represented using a node class with a list of child nodes
BFS can be implemented using a queue data structure
Iterate through the queue and add child nodes to the queue
Pop the node from the queue and process it
Repeat until the queue is empty
Q113. Write the code to find inorder successor of given node in binary tree
Code to find inorder successor of given node in binary tree
Check if the given node has a right subtree, if yes then find the leftmost node in the right subtree
If the given node does not have a right subtree, then traverse up the tree until we reach a node which is the left child of its parent
If we reach the root and the given node is the rightmost node, then there is no inorder successor
Q114. Find the nth power of a number in shortest computational time
Use exponentiation by squaring algorithm to find nth power of a number in shortest computational time.
Use recursion to divide the power by 2 and multiply the base accordingly
If power is odd, multiply the base with the result of recursive call
If power is negative, take reciprocal of base and make power positive
Handle edge cases like power=0 and base=0 or 1
Time complexity is O(log n)
Q115. Check the no of repeated occurences of a substring in a string
Count the number of times a substring appears in a string.
Use a loop to iterate through the string and check for the substring at each index.
Use the count() method to count the number of occurrences of the substring.
Consider using regular expressions to find all occurrences of the substring.
Handle edge cases such as empty strings or substrings.
Q116. You are given file pointer and integer n, write c code for printing last “n” lines in that file
C code to print last n lines of a file given file pointer and integer n.
Use fseek() to move the file pointer to the end of the file
Count the number of newline characters encountered from the end of the file until n lines are found
Use fgets() to read and print the last n lines
Q117. Given a binary search tree and a no. N in the tree, print the leftmost node at the same level as N
Print the leftmost node at the same level as a given node in a binary search tree.
Traverse the tree level by level using BFS
Keep track of the leftmost node at each level
Return the leftmost node at the level of the given node
If the given node is not found, return null
Q118. Search for an element in a rotated sorted array (of course in sublinear time!)
Search for an element in a rotated sorted array in sublinear time.
Use binary search to find the pivot point where the array is rotated.
Determine which half of the array the target element is in.
Perform binary search on the appropriate half of the array to find the target element.
Time complexity is O(log n).
Q119. What is IPC? What are its types? compare them
IPC stands for Inter-Process Communication. It is a mechanism that allows processes to communicate with each other.
Types of IPC include shared memory, message passing, and pipes.
Shared memory allows processes to share a portion of memory.
Message passing involves sending messages between processes.
Pipes are a unidirectional form of communication.
Shared memory is faster than message passing, but message passing is more reliable.
Pipes are useful for simple communication between ...read more
Q120. Who is the founder of c language?
The founder of C language is Dennis Ritchie.
Dennis Ritchie is the creator of the C programming language.
He developed C language at Bell Labs in the early 1970s.
C language is widely used for system programming and developing other programming languages.
Q121. Find the nth element in a tribonacci(a variation of Fibonacci) series. t(n)=t(n-1)+t(n-2)+t(n-3)
Find the nth element in a tribonacci series.
Use recursion to solve the problem.
Handle base cases for n=0, n=1, and n=2.
For n>2, use the formula t(n)=t(n-1)+t(n-2)+t(n-3).
Return the value of t(n) for the given n.
Q122. Given a node in a binary tree, find the leftmost node in the same level
Find the leftmost node in the same level as a given node in a binary tree.
Traverse the tree level by level using BFS
For each level, keep track of the leftmost node encountered
Return the leftmost node in the level of the given node
Q123. Find the nth largest number in a binary tree
Find the nth largest number in a binary tree
Traverse the tree in-order and store the values in an array
Return the (n-1)th index of the sorted array in descending order
Use a max heap to keep track of the largest n elements
Q124. Merge two sorted linked list and write testcases
Merging two sorted linked lists and writing test cases.
Create a new linked list to store the merged list
Compare the first nodes of both lists and add the smaller one to the new list
Repeat until one of the lists is empty, then add the remaining nodes to the new list
Write test cases to cover all possible scenarios, including empty lists and lists of different lengths
Q125. Find the intersection point of two linked list
Find the intersection point of two linked lists.
Traverse both lists and find their lengths.
Move the head of the longer list to make both lists equal in length.
Traverse both lists in parallel until the intersection point is found.
Q126. When was c language developed?
C language was developed in 1972.
Developed by Dennis Ritchie at Bell Labs.
First appeared in 1972.
Influential in the development of many other programming languages like C++, Java, and Python.
Q127. code optimization problem with reduced time complexity
Optimizing code for reduced time complexity by using efficient algorithms and data structures.
Use efficient data structures like hash tables, binary search trees, or priority queues.
Avoid nested loops and try to reduce the number of iterations.
Utilize dynamic programming or memoization to store and reuse intermediate results.
Consider using bitwise operations for certain calculations.
Optimize recursive functions by eliminating redundant calculations.
Q128. What is c language ?
C language is a high-level programming language known for its efficiency and flexibility.
C language was developed by Dennis Ritchie at Bell Labs in the early 1970s.
It is widely used for system programming, developing operating systems, and embedded systems.
C is a procedural programming language with a rich set of built-in functions and operators.
Example: printf() function is used to print output in C language.
Design an elevator system for efficient vertical transportation.
Divide building into zones to optimize elevator usage.
Implement algorithms for efficient elevator scheduling.
Include safety features like emergency stop buttons and overload sensors.
Consider user interface for passengers to select floors and monitor elevator status.
Q130. What type of program
I'm sorry, could you please clarify what type of program you are referring to?
Ask for more information about the program in question
Provide examples of different types of programs
Clarify the context of the question
Q131. Tell me about graph
A graph is a data structure that consists of nodes (vertices) connected by edges.
Nodes represent entities and edges represent relationships between entities
Graphs can be directed or undirected
Common graph algorithms include depth-first search and breadth-first search
More about working at Microsoft Corporation
Top HR Questions asked in Eskag Pharma
Interview Process at Eskag Pharma
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month