Freshworks
Botree Software International Interview Questions and Answers
Q1. Invert a Binary Tree
You are provided with a Binary Tree and one of its leaf nodes. Your task is to invert this binary tree, making sure to adhere to the following guidelines:
- The given leaf node becomes the r...read more
Invert a binary tree with a given leaf node as the new root, following specific guidelines.
Start by identifying the leaf node provided in the input.
Follow the guidelines to invert the binary tree with the leaf node as the new root.
Ensure that the left child becomes the right child of the new root if available, and the parent becomes the left child.
Implement the inversion process for each test case and output the resulting binary tree in the same format as the input.
Q2. Merge Two Sorted Arrays Problem Statement
Given two sorted integer arrays ARR1
and ARR2
of size M and N, respectively, merge them into ARR1
as one sorted array. Assume that ARR1
has a size of M + N to hold all ...read more
Merge two sorted arrays into one sorted array in place.
Iterate from the end of both arrays and compare elements to merge in place
Use two pointers to keep track of the current position in each array
Update the elements in ARR1 from the end to the beginning
Q3. Deepest Left Leaf Node Problem Statement
You are provided with a binary tree consisting of 'N' nodes. Your goal is to identify the deepest leaf node that is a left child of some node within the given binary tre...read more
Identify the deepest left leaf node in a binary tree.
Traverse the binary tree in level order to find the deepest left leaf node.
Keep track of the maximum depth and the value of the deepest left leaf node found so far.
Return the value of the deepest left leaf node at the end.
Q4. Valid Parentheses Problem Statement
Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.
Input:
The first line contains an integer...read more
The task is to determine if a given string consisting of parentheses is balanced or not.
Iterate through each character in the string and use a stack to keep track of opening parentheses
If an opening parenthesis is encountered, push it onto the stack
If a closing parenthesis is encountered, check if it matches the top of the stack. If it does, pop the stack, else return 'Not Balanced'
At the end, if the stack is empty, return 'Balanced', else return 'Not Balanced'
Q5. Reverse Integer Problem Statement
Given a 32-bit signed integer N
, your task is to return the reversed integer. If reversing the integer causes overflow, return -1
.
Input:
The first line contains an integer 'T'...read more
Reverse a 32-bit signed integer and handle overflow cases.
Implement a function to reverse the given integer.
Check for overflow conditions and return -1 if overflow occurs.
Use 32-bit capacity data types only.
Example: For input 123, output should be 321.
Q6. Sub Sort Problem Statement
You are given an integer array ARR
. Determine the length of the shortest contiguous subarray which, when sorted in ascending order, results in the entire array being sorted in ascendi...read more
Find the length of the shortest subarray that needs to be sorted to make the entire array sorted in ascending order.
Iterate from left to right to find the first element out of order.
Iterate from right to left to find the last element out of order.
Calculate the length of the subarray between the out of order elements.
More about working at Freshworks
Interview Process at Botree Software International
Top Graduate Trainee Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month