
Bounteous x Accolite

40+ Bounteous x Accolite Interview Questions and Answers for Freshers
Q1. Loot Houses Problem Statement
A thief is planning to steal from several houses along a street. Each house has a certain amount of money stashed. However, the thief cannot loot two adjacent houses. Determine the...read more
Determine the maximum amount of money a thief can steal from houses without looting two consecutive houses.
Create an array 'dp' to store the maximum money that can be stolen up to the i-th house.
Iterate through the houses and update 'dp' based on whether the current house is stolen or not.
Return the maximum value in 'dp' as the answer.
Example: For input N=4 and values=[6, 7, 1, 30], the output should be 36.
Q2. Topological Sort Problem Statement
You are given a directed acyclic graph (DAG). Your task is to perform topological sorting of the graph and return any valid ordering.
Explanation:
A directed acyclic graph is ...read more
Implement a function to perform topological sorting on a directed acyclic graph (DAG) and return any valid ordering.
Create a graph representation using adjacency list or matrix
Perform depth-first search (DFS) to find the topological ordering
Use a stack to keep track of the ordering
Return the ordering as an array of integers
Q3. What is finally and will it execute if System.exit() is called?
Finally is a block of code that executes after try-catch block. It will not execute if System.exit() is called.
Finally block is used to execute a block of code after try-catch block
It will execute even if an exception is thrown
Finally block will not execute if the JVM exits before the block is executed
System.exit() terminates the JVM and finally block will not execute
Q4. Find all palindromic strings in a string program
Program to find all palindromic strings in a given string.
Iterate through the string and check for palindromic substrings using two pointers.
Add the palindromic substrings to an array of strings.
Return the array of palindromic strings.
Q5. Tree traversal to find minimum number
Use tree traversal to find the minimum number in a tree structure.
Start at the root node and compare it with its children to find the minimum value.
Use depth-first search or breadth-first search to traverse the tree.
Keep track of the minimum value found so far as you traverse the tree.
Consider implementing a recursive function to traverse the tree efficiently.
Q6. Find 2nd max salary- SQL
SQL query to find the 2nd highest salary in a table.
Use ORDER BY and LIMIT to sort and select the 2nd highest salary.
Use subquery to avoid duplicates if necessary.
Q7. Maximum Subarray Problem Statement
Ninja has been given an array, and he wants to find a subarray such that the sum of all elements in the subarray is maximum.
A subarray 'A' is considered greater than a subarr...read more
The task is to find the subarray with the maximum sum in a given array.
Iterate through the array and keep track of the current sum and maximum sum seen so far.
If the current sum becomes negative, reset it to 0 as it won't contribute to the maximum sum.
Compare the maximum sum with the sum of the current subarray to update the result.
Handle cases where all elements are negative by returning the maximum element in the array.
Consider edge cases like empty array or array with only...read more
Q8. Rotting Oranges Problem Statement
You are given a grid containing oranges where each cell of the grid can contain one of the three integer values:
- 0 - representing an empty cell
- 1 - representing a fresh orange...read more
Find the minimum time required to rot all fresh oranges in a grid.
Use Breadth First Search (BFS) to simulate the rotting process
Track the time taken to rot all oranges and return -1 if any fresh oranges remain
Handle edge cases like no fresh oranges or all oranges already rotten
Consider using a queue to efficiently process adjacent oranges
Q9. Intersection of Linked List Problem
You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.
Your task is to determine the data...read more
Find the node where two linked lists merge, return -1 if no merging occurs.
Traverse both lists to find their lengths and the difference in lengths
Move the pointer of the longer list by the difference in lengths
Traverse both lists simultaneously until they meet at the merging point
Q10. Reverse Linked List Problem Statement
Given a Singly Linked List of integers, your task is to reverse the Linked List by altering the links between the nodes.
Input:
The first line of input is an integer T, rep...read more
Reverse a singly linked list by altering the links between nodes.
Iterate through the linked list and reverse the links between nodes
Use three pointers to keep track of the current, previous, and next nodes
Update the links between nodes to reverse the list
Return the head of the reversed linked list
Q11. Merge K Sorted Arrays Problem Statement
You are provided with 'K' different arrays/lists, each sorted in ascending order. Your task is to merge all these arrays/lists into one sorted array/list in ascending ord...read more
Merge K sorted arrays into one sorted array in ascending order.
Iterate through all arrays/lists and merge them into one sorted array using a priority queue or merge sort algorithm.
Ensure to handle edge cases like empty arrays/lists or arrays/lists with different sizes.
Time complexity can be optimized by using a min-heap or priority queue to efficiently merge the arrays/lists.
Q12. Left View of a Binary Tree Problem Statement
Given a binary tree, your task is to print the left view of the tree.
Example:
Input:
The input will be in level order form, with node values separated by a space. U...read more
Print the left view of a binary tree given in level order form.
Traverse the tree level by level and print the first node of each level (leftmost node).
Use a queue to perform level order traversal.
Keep track of the current level and print the first node encountered at each level.
Q13. Maximum Path Sum Between Two Leaves Problem Description
You are provided with a non-empty binary tree in which each node contains a non-negative integer value. Your task is to find and return the maximum possib...read more
Find the maximum path sum between two leaf nodes in a binary tree.
Traverse the tree to find the maximum path sum between two leaf nodes.
Keep track of the maximum sum found so far.
Consider all possible paths between leaf nodes.
Handle cases where the tree has only a single leaf node.
Implement a recursive function to calculate the maximum path sum.
Q14. Majority Element Problem Statement
Given an array/list 'ARR' consisting of 'N' integers, your task is to find the majority element in the array. If there is no majority element present, return -1.
Example:
Inpu...read more
Find the majority element in an array, return -1 if no majority element exists.
Iterate through the array and keep track of the count of each element using a hashmap.
Check if any element's count is greater than floor(N/2) to determine the majority element.
Return the majority element or -1 if no majority element exists.
Q15. N-th Node From The End Problem Statement
You are given a Singly Linked List of integers. The task is to find the N-th node from the end of the list.
Example:
Input:
If the given list is (1 -> -2 -> 0 -> 4) and ...read more
Find the N-th node from the end of a Singly Linked List of integers.
Traverse the list to find the length L of the list.
Calculate the position of the N-th node from the beginning as L - N + 1.
Traverse the list again to reach the calculated position and return the node's value.
Q16. LCA of Binary Tree Problem Statement
You are given a binary tree consisting of distinct integers and two nodes, X
and Y
. Your task is to find and return the Lowest Common Ancestor (LCA) of these two nodes.
The ...read more
Find the Lowest Common Ancestor (LCA) of two nodes in a binary tree.
Traverse the binary tree to find the paths from the root to nodes X and Y.
Compare the paths to find the last common node, which is the LCA.
Handle cases where one node is an ancestor of the other or when one node is the LCA itself.
Q17. Reverse Words in a String: Problem Statement
You are given a string of length N
. Your task is to reverse the string word by word. The input may contain multiple spaces between words and may have leading or trai...read more
Reverse words in a string while handling leading/trailing spaces and multiple spaces between words.
Split the input string by spaces to get individual words
Reverse the list of words
Join the reversed words with a single space in between
Handle leading/trailing spaces by stripping them before and after reversing
Q18. Minimum Time To Solve The Problems
Given 'N' subjects, each containing a certain number of problems, and 'K' friends, assign subjects to friends such that each subject goes to exactly one friend, maintaining co...read more
Assign subjects to friends to minimize maximum workload, find minimum time for most loaded friend.
Sort subjects in descending order
Assign subjects to friends one by one until all subjects are assigned
The maximum workload will be the sum of problems assigned to the friend with the most problems
Return the maximum workload as the minimum time required
Q19. Sum Root to Leaf Numbers
You are given an arbitrary binary tree consisting of N nodes, each associated with an integer value from 1 to 9. Each root-to-leaf path can be considered a number formed by concatenatin...read more
Find the total sum of all root to leaf paths in a binary tree formed by concatenating node values.
Traverse the binary tree from root to leaf nodes, keeping track of the current path sum
Add the current path sum to the total sum when reaching a leaf node
Use modulo (10^9 + 7) to handle large outputs
Grammar in compiler design defines the syntax and structure of a programming language.
Grammar specifies the rules for forming valid statements in a programming language.
It consists of a set of production rules that define how valid programs can be constructed.
There are different types of grammars such as context-free grammar, regular grammar, etc.
Example: In C programming language, the grammar specifies that a for loop should have a specific syntax like 'for(initialization; c...read more
Q21. 1. Write a code to split an array of integers into two subarray where both the array has equal sum.
Code to split an array of integers into two subarrays with equal sum.
Iterate through the array and calculate the total sum.
Divide the sum by 2 to get the target sum for each subarray.
Use dynamic programming to find a subset of the array that adds up to the target sum.
Return the two subarrays.
Example: [1, 2, 3, 4, 5, 6] -> [1, 2, 3, 6], [4, 5]
Example: [1, 2, 3, 4, 5] -> [1, 4, 5], [2, 3]
Q22. To write code to build up a binary tree from scratch (implement a BST) and then to write all the methods like all the tree traversal algo, and all other stuffs.
Implementing a binary search tree and its traversal methods.
Start by defining a Node class with left and right child pointers.
Implement insert() method to add nodes to the tree.
Implement inorder(), preorder(), and postorder() traversal methods.
Implement search() method to find a node in the tree.
Implement delete() method to remove a node from the tree.
Consider edge cases like empty tree, duplicate nodes, etc.
NP problems are decision problems that can be verified in polynomial time, while NP-Hard problems are at least as hard as the hardest problems in NP.
NP problems can be verified in polynomial time but not necessarily solved in polynomial time.
NP-Hard problems are at least as hard as the hardest problems in NP, but may not be in NP themselves.
Examples of NP problems include the subset sum problem and the traveling salesman problem.
Examples of NP-Hard problems include the travel...read more
A token in compiler design is a basic unit of syntax that the compiler can understand and process.
Tokens are the smallest units of a program that are meaningful to the compiler.
Examples of tokens include keywords, identifiers, operators, and punctuation symbols.
Tokens are generated by the lexical analysis phase of the compiler.
Tokens are used by the parser to build the abstract syntax tree of the program.
Q25. Ninja and the Maze Problem Statement
Ninja is stuck in a maze represented as a 2D grid. He can move in four directions (Up, Down, Left, Right) until he hits a wall ('1'). Once stopped, he can choose a new direc...read more
The problem involves determining if a ninja can reach the destination in a maze by moving in four directions until hitting a wall.
Create a function that takes in the maze, starting point, and destination coordinates as input.
Implement a recursive algorithm to explore all possible paths in the maze.
Check if the destination can be reached from the starting point by moving in four directions.
Return 'True' if a path exists, otherwise return 'False'.
Q26. 2. find unique character in a window of k size in a string
Find unique characters in a window of k size in a string.
Use a sliding window approach.
Maintain a hash table to keep track of character frequency.
Remove characters from hash table as the window slides.
Q27. 1. If you given a no return its corresponding excel no.
Convert given no to corresponding excel no.
Excel no starts from 1 and goes up to 16384
Excel no is calculated using column and row numbers
For example, 1 corresponds to A, 27 corresponds to AA, 28 corresponds to AB, and so on
A regular language is a language that can be recognized by a finite automaton.
Regular languages can be described by regular expressions.
Regular languages are closed under union, concatenation, and Kleene star operations.
Examples of regular languages include the set of all strings over an alphabet that contain an even number of 'a's.
Q29. Kth Largest Element Problem
Given an array containing N
distinct positive integers and a number K
, determine the Kth largest element in the array.
Example:
Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more
Find the Kth largest element in an array of distinct positive integers.
Sort the array in non-increasing order and return the Kth element.
Use a priority queue or quick select algorithm for efficient solution.
Ensure the array contains distinct positive integers for accurate result.
Q30. Left Rotations of an Array
Given an array of size N
and Q
queries, each query requires left rotating the original array by a specified number of elements. Return the modified array for each query.
Input:
The fi...read more
Rotate an array left by a specified number of elements for each query.
Iterate through each query and rotate the array left by the specified number of elements using array slicing.
Handle cases where the number of rotations exceeds the length of the array by taking the modulo of the rotations.
Return the modified array after each query.
Q31. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
Calculate the total amount of rainwater that can be trapped between given elevations in an array.
Iterate through the array and calculate the maximum height on the left and right of each bar.
Calculate the amount of water that can be trapped at each bar by taking the minimum of the maximum heights on the left and right.
Sum up the trapped water at each bar to get the total trapped water for the entire array.
Q32. Distinct Occurrences Problem Statement
You are given two strings 'A' and 'B' of lengths 'N' and 'M' respectively. Your task is to determine how many distinct ways string 'B' occurs as a subsequence in string 'A...read more
Count the number of distinct occurrences of one string as a subsequence in another string.
Iterate through string A and string B to find all occurrences of B as a subsequence in A.
Use dynamic programming to keep track of the number of distinct occurrences.
Handle edge cases such as empty strings or strings of different lengths.
Example: For strings A='aabbcc' and B='abc', there are 3 distinct occurrences of B in A.
Q33. Median of Two Sorted Arrays
Given two sorted arrays A
and B
of sizes N
and M
, find the median of the merged array formed by combining arrays A
and B
. If the total number of elements, N + M
, is even, the median ...read more
Find the median of two sorted arrays by merging them and calculating the median of the combined array.
Merge the two sorted arrays into one sorted array.
Calculate the median of the merged array based on the total number of elements.
If the total number of elements is even, take the mean of the two middle elements as the median.
Q34. Distance Between Two Nodes in a Binary Tree
Given a binary tree and the values of two distinct nodes, determine the distance between these two nodes in the tree. The distance is defined as the minimum number of...read more
Calculate the distance between two nodes in a binary tree.
Traverse the tree to find the paths from the root to each node
Find the lowest common ancestor of the two nodes
Calculate the distance by summing the distances from each node to the common ancestor
Q35. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an array of 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of 0s, 1s, and 2s while iterating through the array.
Swap elements based on the values encountered to sort the array in-place.
Time complexity should be O(N) and space complexity should be O(1).
There are 3 levels of normalization in database management systems.
First Normal Form (1NF) - Eliminate duplicate data and ensure data is stored in a tabular format.
Second Normal Form (2NF) - Meet 1NF requirements and ensure all non-key attributes are fully functional dependent on the primary key.
Third Normal Form (3NF) - Meet 2NF requirements and ensure that there are no transitive dependencies between non-key attributes.
The sub-parts or phases of the analysis part in compiler design include lexical analysis, syntax analysis, and semantic analysis.
Lexical analysis involves breaking the input into tokens such as keywords, identifiers, and operators.
Syntax analysis checks the structure of the tokens to ensure they conform to the grammar rules of the language.
Semantic analysis verifies the meaning of the program by checking for type compatibility and other semantic rules.
Examples include lexing ...read more
Segmentation in operating systems is a memory management technique where memory is divided into segments of variable sizes.
Segments are logical units of a program such as code, data, stack, etc.
Each segment has its own base address and length.
Segmentation allows for more efficient memory management and protection.
Examples include Intel x86 architecture with segment registers like CS, DS, SS, etc.
Q39. Programming - find the frequency of given character in a sorted string.
Use binary search to find the first and last occurrence of the character, then calculate the frequency.
Use binary search to find the first occurrence of the character in the string.
Use binary search to find the last occurrence of the character in the string.
Calculate the frequency by subtracting the indices of the last and first occurrences and adding 1.
Q40. OOPs concepts, and their pillars. Design a Vehicle class, by understanding the requirements
OOPs concepts and pillars. Design a Vehicle class based on requirements.
OOPs concepts: Abstraction, Encapsulation, Inheritance, Polymorphism
Vehicle class requirements: attributes like make, model, year, methods like start, stop, accelerate
Q41. What are different sorting algorithms?
Q42. Print factorial of n through recursion Sum of all n numbers
Factorial of n and sum of n numbers using recursion
Create a recursive function to calculate factorial of n
Use a recursive function to calculate the sum of all n numbers
Handle base cases for both factorial and sum calculations
Example: Factorial of 5 = 5 * 4 * 3 * 2 * 1 = 120, Sum of first 5 numbers = 1 + 2 + 3 + 4 + 5 = 15
Q43. Top view of a binary tree
A top view of a binary tree shows the nodes visible from the top when looking down from the root node.
The top view of a binary tree can be obtained by performing a level order traversal and keeping track of the horizontal distance of each node from the root.
Nodes with the same horizontal distance are at the same level in the top view.
Example: For the binary tree 1 -> 2 -> 3 -> 4 -> 5, the top view would be 1 -> 2 -> 3 -> 4 -> 5.
Top HR Questions asked in Bounteous x Accolite for Freshers
Interview Process at Bounteous x Accolite for Freshers

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

