Sigmoid
BuildMyInfra Interview Questions and Answers
Q1. Given a binary string,find out the max length of substring having equal number of 1 and 0
Find max length of substring with equal 1s and 0s in a binary string.
Use a hash table to store the difference between the count of 1s and 0s seen so far.
If the difference is 0, update the max length seen so far.
If the difference is already in the hash table, update the max length using the current index and the index where the difference was first seen.
Return the max length.
Example: '1100010110' -> 8
Q2. Leetcode's sort 0 1 array in place
Sort an array of 0s and 1s in place without using extra space.
Use two pointers approach - one for 0s and one for 1s.
Swap elements at the two pointers until all 0s are on the left and 1s on the right.
Q3. Validate binary search tree.
Validate if a binary tree is a binary search tree
In-order traversal should result in a sorted array
Check if each node's value is within the correct range
Recursively validate left and right subtrees
Q4. Reverse K group linked list.
Reverse K group linked list
Iterate through the linked list in groups of size K
Reverse each group of K nodes
Connect the reversed groups back together
Q5. Nearest Left Greater element.
Find the nearest element on the left side of an array that is greater than the current element.
Iterate through the array from right to left.
Use a stack to keep track of elements that are greater than the current element.
Pop elements from the stack until finding a greater element or the stack is empty.
If a greater element is found, that is the nearest left greater element.
If the stack is empty, there is no nearest left greater element.
Q6. Leetcode's Maximum Path Sum
Find the maximum path sum in a binary tree
Use recursion to traverse the binary tree and calculate the maximum path sum at each node
At each node, calculate the maximum path sum that includes the current node and return the maximum path sum that does not include the current node
Update a global variable to keep track of the maximum path sum found so far
Interview Process at BuildMyInfra
Top Software Development Engineer II Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month