
Buyhatke

Buyhatke Interview Questions and Answers
Q1. Shortest Route Problem Statement
You want to visit your friend’s house located at some position in an infinite grid starting from origin (0, 0). You can move in four directions: East (E), West (W), North (N), a...read more
Given a directional string representing a route to a friend's house in an infinite grid, find the shortest lexicographically smallest route to reach the destination.
Iterate through the directional string and keep track of the movements in each direction (E, W, N, S).
Calculate the final position based on the movements and find the shortest lexicographically smallest route to reach that position.
Consider the constraints and optimize the solution to handle large inputs efficient...read more
Q2. 0/1 Knapsack Problem Statement
A thief is planning to rob a store and can carry a maximum weight of 'W' in his knapsack. The store contains 'N' items where the ith item has a weight of 'wi' and a value of 'vi'....read more
Yes, the 0/1 Knapsack problem can be solved using dynamic programming with a space complexity of not more than O(W).
Use a 1D array to store the maximum value that can be stolen for each weight capacity from 0 to W.
Iterate through each item and update the array based on whether including the item would increase the total value.
The final value in the array at index W will be the maximum value that can be stolen.
Q3. Time to Burn Tree Problem
You are given a binary tree consisting of 'N' unique nodes and a start node where the burning will commence. The task is to calculate the time in minutes required to completely burn th...read more
Calculate the time in minutes required to completely burn a binary tree starting from a given node.
Start burning from the given node and spread fire to adjacent nodes each minute
Track the time taken for each node to burn completely
Return the maximum time taken to burn the entire tree
Q4. Find LCA of a binary tree, standard dsa medium problem
LCA of a binary tree is the lowest common ancestor of two nodes in the tree.
Traverse the tree from the root node to find the paths from root to the two given nodes.
Compare the paths to find the last common node, which is the LCA.
Use recursion to solve the problem efficiently.
Handle edge cases like if one of the nodes is the ancestor of the other.
Q5. Why did you use Swift over React Native?
Swift was chosen for its performance, native iOS support, and better integration with Apple's ecosystem.
Swift offers better performance compared to React Native due to its native code execution.
Swift provides seamless integration with Apple's ecosystem, allowing for better utilization of iOS features.
Swift is the preferred choice for developing iOS apps as it is the native language for iOS development.
React Native may have limitations in accessing certain iOS features or APIs...read more
Q6. What is Observable in Swift?
Observable in Swift is a property wrapper that allows for automatic notifications when the value changes.
Observable is a property wrapper introduced in Swift 5.1.
It can be used with any property that needs to be observed for changes.
When the value of the property changes, any views using that property will be automatically updated.
Example: @Published var score: Int = 0
Q7. implement depth first search in tree
Depth first search in tree is implemented using recursion to explore each branch fully before moving to the next.
Start at the root node and recursively visit each child node before moving to the next sibling node.
Use a stack to keep track of nodes to visit, pushing children onto the stack before siblings.
Base case is when the current node is null or a leaf node, then backtrack to the parent node.
Q8. what are foreign keys
Foreign keys are columns in a database table that reference the primary key of another table, establishing a relationship between the two tables.
Foreign keys ensure referential integrity in a database by enforcing relationships between tables.
They help maintain data consistency by preventing actions that would violate the relationships between tables.
For example, in a database with tables for 'orders' and 'customers', the 'customer_id' column in the 'orders' table would be a ...read more
Interview Process at Buyhatke

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

