Hike
10+ Distributors Basket (gala) Interview Questions and Answers
Q1. Given a cartesian x-y plane and lot of points in that plane with x and y coordinates and 1 more point(say x,y) is given, so we have to find all the points in that plane which are lying in a radius of length r f...
read moreGiven a point and a radius, find all points in a cartesian plane within the radius.
Calculate the distance between the given point and all other points in the plane using the distance formula.
If the distance is less than or equal to the radius, add the point to the result set.
Return the result set of points within the radius of the given point.
Q2. how you will find out 3rd smallest element from an array
To find the 3rd smallest element from an array, sort the array and return the element at index 2.
Sort the array in ascending order
Return the element at index 2
If the array has less than 3 elements, return null
Q3. Designing a LRU Cache which is thread safe and can be scaled
Design a thread-safe LRU cache that can be scaled.
Use a ConcurrentHashMap to ensure thread safety.
Implement a doubly linked list to keep track of the least recently used items.
Use a HashMap to store the cache items for fast retrieval.
Implement a size limit for the cache and remove the least recently used item when the limit is reached.
To scale the cache, use a distributed cache like Redis or Memcached.
Q4. Write code to get maximum and second maximum element of a stack. The given function should be in O(1) complexity
Code to get max and second max element of a stack in O(1) complexity.
Create two variables to store max and second max values
Update the variables whenever a new element is pushed or popped from the stack
Return the max and second max values when required
Q5. Given a biotonic array ( first numbers increase and then decrease ) write code to search a given number. Time complexity O(logn)
Code to search a given number in a biotonic array with O(logn) time complexity.
Use binary search to find the peak element in the array.
Divide the array into two subarrays and perform binary search on each subarray.
Return the index of the element if found, else return -1.
Q6. How does Stack work internally and what data it holds?
Stack is a data structure that follows LIFO (Last In First Out) principle.
Stack holds a collection of elements
It has two main operations: push (adds element to top) and pop (removes element from top)
It also has peek operation (returns top element without removing it)
Stack can be implemented using arrays or linked lists
Examples: undo-redo functionality in text editors, back-forward navigation in web browsers
Q7. A sorted array is rotated K times. Sort it in o(n) traversal without extra space
Sort a rotated sorted array in O(n) time without extra space
Find the index of the minimum element using binary search
Reverse the two subarrays on either side of the minimum element
Reverse the entire array
Example: [4,5,6,7,0,1,2] -> [0,1,2,4,5,6,7]
Q8. do you know spell checker in micro soft word
Yes, spell checker is a built-in feature in Microsoft Word.
Spell checker automatically checks for spelling errors as you type.
It underlines misspelled words in red and suggests corrections.
You can also customize the spell checker settings and add words to the dictionary.
To access the spell checker, go to the Review tab and click on Spelling & Grammar.
Alternatively, you can use the shortcut key F7 to run the spell checker.
Q9. two pair with a given sum in a bst with o(log n) space
Finding two pairs with a given sum in a BST using O(log n) space.
Traverse the BST in-order and store the nodes in an array
Use two pointers approach to find the pairs with the given sum
Time complexity: O(n), Space complexity: O(log n)
Optimized approach: Use two stacks to traverse the BST in-order and find the pairs
Time complexity: O(log n), Space complexity: O(log n)
Q10. K random numbers from infinite stream of array with equal probability
To select k random numbers from an infinite stream of array with equal probability.
Use reservoir sampling algorithm to randomly select k numbers from the stream
Maintain a reservoir array of size k to store the selected numbers
For each incoming number, generate a random number between 0 and the total count of numbers seen so far
If the generated number is less than k, replace the corresponding number in the reservoir array with the incoming number
At the end, the reservoir array...read more
Q11. How to analyze usage history of a application
Usage history of an application can be analyzed by tracking user actions and behavior.
Collect data on user interactions with the application
Analyze the frequency and duration of usage
Identify patterns and trends in user behavior
Use data visualization tools to present findings
Consider user feedback and reviews for additional insights
Q12. Designing a file sharing mechanism between two users
Design a file sharing mechanism between two users
Use a secure protocol like HTTPS or SFTP
Implement access control to ensure only authorized users can access the files
Consider implementing encryption to protect the files during transit and at rest
Provide a user-friendly interface for uploading and downloading files
Implement version control to track changes made to the files
Consider implementing a notification system to alert users of new file uploads or changes
Q13. Implement Inorder Traversal with and without using recursion
Inorder Traversal can be implemented using recursion or without recursion.
Inorder Traversal using recursion involves traversing the left subtree, visiting the root node, and then traversing the right subtree.
Inorder Traversal without recursion involves using a stack to keep track of the nodes to be visited.
For each node, push it onto the stack and traverse its left subtree until there are no more left nodes.
Pop the top node from the stack, visit it, and then traverse its righ...read more
Q14. Reverse alternate levels of a binary tree
Reverse alternate levels of a binary tree
Traverse the tree level by level
Reverse the nodes of alternate levels
Use a queue or stack to keep track of nodes at each level
Recursively apply the same process to the children of reversed nodes
Q15. Why manhole is round ?
Manholes are round because it prevents them from falling into the hole and allows for easy movement of the cover.
Round covers cannot fall into the hole as they cannot fit through diagonally
Round covers can be easily moved in any direction
Round shape distributes weight evenly
Round shape is easier to manufacture and install
Q16. Explain the architecture of transformer models.
Q17. Median of a stream of array
Finding the median of a stream of array in real-time.
Use two heaps to keep track of the median
Maintain a max heap for the lower half and a min heap for the upper half
If the heaps are balanced, the median is the average of the top elements of both heaps
If the heaps are unbalanced, the median is the top element of the heap with more elements
Q18. Lru Cache leet problem in deep
Implement a Least Recently Used (LRU) cache
Use a combination of a doubly linked list and a hashmap to efficiently implement the LRU cache
When a new element is accessed, move it to the front of the linked list and update the hashmap
When the cache is full, remove the least recently used element from the end of the linked list and the hashmap
Top HR Questions asked in Distributors Basket (gala)
Interview Process at Distributors Basket (gala)
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month