
Bounteous x Accolite

100+ Bounteous x Accolite Interview Questions and Answers
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. Total time: 110 mins 1. Find missing and duplicate numbers from given array(algo, code, optimization, dry run, complexity analysis) 2. Flatten Binary tree to Linked List Conversion (algo, code, optimization, dr...
read moreInterview questions for Software Engineer position
Array manipulation and linked list operations
Tree data structure and balancing techniques
Database concepts and differences between SQL and NoSQL
Web development frameworks and protocols
Concepts of Deadlock and Race Condition
Use of pointers in function oriented programming and their absence in Java
Q4. Can you make a constructor private in Cpp, if not what error will you get (Compile Time Error or Runtime Error)
Yes, a constructor can be made private in C++ to restrict object creation outside the class.
Private constructors are used in Singleton design pattern to ensure only one instance of the class is created.
If a constructor is made private, it can only be accessed by the member functions of the class.
Attempting to create an object of a class with a private constructor outside the class will result in a compile-time error.
Q5. 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
Q6. What is the difference between Binary Tree and Binary Search Tree
Binary Tree is a tree data structure where each node has at most two children. Binary Search Tree is a binary tree with the property that the left subtree of a node contains only nodes with keys lesser than the node's key and the right subtree of a node contains only nodes with keys greater than the node's key.
Binary Tree can have any values in the nodes, while Binary Search Tree has a specific order of values.
Binary Search Tree allows for efficient searching, insertion, and ...read more
Q7. What are the Dynamic-link library (DLL) in Cpp and its use?
DLL is a library of executable functions and data that can be used by a Windows application.
DLLs are loaded at runtime and can be shared by multiple applications.
They allow for modular programming and reduce memory usage.
DLLs can be used for device drivers, system utilities, and application extensions.
Examples of DLLs include kernel32.dll, user32.dll, and msvcr100.dll.
Q8. What are function pointers and the differences between normal function and function pointers?
Function pointers are pointers that point to the memory address of a function. They can be passed as arguments or returned from a function.
Function pointers allow for dynamic function calls at runtime
Function pointers can be used to implement callbacks
Function pointers can be used to implement polymorphism
Normal functions are called directly, while function pointers are called indirectly
Function pointers can be assigned to NULL to indicate that they do not point to a valid fu...read more
Q9. Explain the diamond problem in Cpp, and how to solve it.
Diamond problem occurs in multiple inheritance when two base classes have a common method. It is solved using virtual inheritance.
Diamond problem occurs when a derived class inherits from two base classes that have a common method.
Virtual inheritance is used to solve the diamond problem.
Virtual inheritance ensures that only one instance of the common base class is created.
Q10. What are the ways to prevent Instantiation of Class?
Ways to prevent instantiation of a class
Declare the class as abstract
Make the constructor private
Implement a static factory method
Throw an exception in the constructor
Use the Singleton pattern
Q11. A tweak to the pair sum problem: there can be any number of elements that add up to the target
The task is to find any number of elements in an array that add up to a given target.
Use a recursive approach to find all possible combinations of elements that add up to the target.
Start with the first element and recursively call the function with the remaining elements and the reduced target.
If the target becomes zero, add the current combination to the result.
If the target becomes negative or there are no more elements, backtrack and try the next element.
Return all the co...read more
Q12. Separate negative and positive numbers in a linked list.
Separate negative and positive numbers in a linked list.
Create two separate linked lists for positive and negative numbers
Traverse the original linked list and add nodes to respective lists
Join the two lists to get the final linked list with separated numbers
Q13. How can you print names of 4 threads in the given order?
Printing names of 4 threads in a given order using an array of strings.
Create an array of strings with the names of the threads in the desired order.
Use a loop to iterate through the array and print each thread name.
Ensure that the threads are started in the same order as the names in the array.
Q14. Delete Kth node from the end of the linked list in single iteration
Delete Kth node from end of linked list in single iteration
Use two pointers, one to traverse the list and another to keep track of Kth node from end
Move both pointers simultaneously until the first pointer reaches the end
Delete the Kth node from end using the second pointer
Q15. Segregate 0's and 1's in array - Dutch National Flag Algo Again
Segregate 0's and 1's in array using Dutch National Flag Algorithm
Use three pointers - low, mid, and high
low points to the first index of 1
mid points to the first index of unknown element
high points to the last index of 1
If arr[mid] is 0, swap arr[low] and arr[mid], increment low and mid
If arr[mid] is 1, increment mid
If arr[mid] is 2, swap arr[mid] and arr[high], decrement high
Q16. Equal Sum Partition along with print that 2 arrays (DP + matrix printing)
Equal Sum Partition problem with DP and matrix printing
The problem involves dividing an array into two subsets with equal sum
Dynamic programming can be used to solve this problem efficiently
A matrix can be used to keep track of the subsets
Printing the subsets can be done by backtracking through the matrix
Q17. 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
Q18. 8. If not engineering then what?
I would have pursued a career in music.
I have been playing the guitar for over 10 years.
I have performed at local gigs and events.
I enjoy writing and composing my own music.
Q19. 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
Q20. How to check for a loop in linked list?
To check for a loop in a linked list, we use the Floyd's cycle-finding algorithm.
Create two pointers, slow and fast, and initialize them to the head of the linked list.
Move slow pointer by one node and fast pointer by two nodes.
If there is a loop, the two pointers will eventually meet.
If there is no loop, the fast pointer will reach the end of the linked list.
Time complexity of this algorithm is O(n) and space complexity is O(1).
Q21. Max multiplication of 3 numbers in an array
Find the maximum multiplication of 3 numbers in an array of strings.
Convert the array of strings to an array of integers.
Sort the array in descending order.
Check the product of first three elements and last two elements with the first element.
Q22. 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'.
Q23. 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
Q24. 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
Q25. 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.
Q26. Project Explanation which includes Q&A as well.
Developed a project management tool for tracking tasks and deadlines.
Implemented user authentication and authorization for secure access.
Utilized a relational database to store project data and user information.
Designed a user-friendly interface with drag-and-drop functionality for task management.
Q27. 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.
Q28. Check if a linked list is circular or not
To check if a linked list is circular, we can use Floyd's cycle-finding algorithm.
Create two pointers, slow and fast, and initialize them to the head of the linked list
Move slow pointer by one node and fast pointer by two nodes
If the linked list is circular, the fast pointer will eventually catch up to the slow pointer
If the linked list is not circular, the fast pointer will reach the end of the list
Time complexity: O(n), Space complexity: O(1)
Q29. Remove duplicates from Linked List. Both variants.
Remove duplicates from Linked List. Both variants.
Variant 1: Using Hash Set to keep track of visited nodes and removing duplicates
Variant 2: Using two pointers to compare each node with all subsequent nodes and removing duplicates
Example: 1->2->3->2->4->3, Output: 1->2->3->4
Q30. 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.
Q31. Calculating the depth of a tree
Calculating the depth of a tree
Depth of a tree is the maximum distance from the root node to any leaf node
Can be calculated recursively by finding the maximum depth of left and right subtrees
Base case is when the node is null, return 0
Q32. 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.
Q33. 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.
Q34. 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.
Q35. 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
Q36. 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
Q37. What are registers in Cpp?
Registers are small, fast memory locations in a CPU that store data for quick access.
Registers are used to store data that is frequently accessed by the CPU.
They are faster than accessing data from RAM.
Registers are limited in number and size.
Examples of registers include the program counter, stack pointer, and general-purpose registers.
Register usage can be optimized for performance in code.
Accessing registers can be done using assembly language.
In C++, registers can be decl...read more
Q38. 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
Q39. what is level order traversal of tree?Write code for the same.
Level order traversal is a tree traversal algorithm that visits nodes level by level.
Start at the root node and visit all nodes at the current level before moving to the next level
Use a queue to keep track of nodes at each level
Enqueue the root node, then dequeue and visit each node while enqueueing its children
Repeat until the queue is empty
Time complexity: O(n), space complexity: O(w) where w is the maximum width of the tree
Q40. Reverse the linked list in groups of k
Reverse a linked list in groups of k
Create a function to reverse a linked list
Iterate through the linked list in groups of k
Reverse each group using the function
Connect the reversed groups back together
Return the new head of the linked list
Q41. Encapsulation and its real-time examples
Encapsulation is a mechanism of wrapping data and code together into a single unit.
Encapsulation helps in achieving data hiding and abstraction.
It provides better control over the data by making it private and accessible only through public methods.
Real-time examples of encapsulation include a car's engine, which is encapsulated and can only be accessed through the car's interface.
Another example is a mobile phone, where the internal components are encapsulated and can only b...read more
Q42. 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.
Q43. What is Runtime polymorphism
Runtime polymorphism is the ability of an object to take on multiple forms during runtime.
It is achieved through method overriding
It allows for more flexibility and extensibility in code
It is a key feature of object-oriented programming
Example: Animal class with different subclasses such as Dog, Cat, and Bird
Q44. 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.
Q45. Coding question: Given a string, find the number of occurences of each character.
Count the number of occurrences of each character in a given string.
Create a dictionary to store the count of each character.
Iterate through the string and update the count in the dictionary.
Return the dictionary with character count.
Q46. 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.
Q47. 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.
Q48. Inheritance and its disadvantages
Inheritance allows a subclass to inherit properties and methods from a superclass, but it has some disadvantages.
Inheritance can lead to tight coupling between classes, making it difficult to modify the superclass without affecting the subclass.
Inheritance can also lead to the creation of deep class hierarchies, which can be difficult to understand and maintain.
Inheritance can result in code duplication if multiple subclasses need to override the same method or property.
Inher...read more
Q49. 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.
Q50. 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
Q51. 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).
Q52. Dutch national flag problem
The Dutch national flag problem is a sorting problem that involves sorting an array of 3 distinct values.
The problem involves sorting an array of 3 distinct values: red, white, and blue.
The goal is to sort the array in-place, without using any additional data structures.
The solution involves using three pointers to keep track of the boundaries between the different values.
Q53. Merge two sorted linked lists
Merge two sorted linked lists
Create a new linked list
Compare the first nodes of both lists and add the smaller one to the new list
Move the pointer of the added node to the next node in the list
Repeat until one of the lists is empty
Add the remaining nodes of the non-empty list to the new list
Q54. 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.
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
Q56. 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.
Q57. 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]
Q58. What is the Look and Say sequence, and how can a program be written to generate the next number in this sequence?
Look and Say sequence is a sequence of numbers where each term is formed by describing the previous term.
Start with the number 1
Read off the digits of the previous number, counting the number of digits in groups of the same digit
For example, starting with 1, the sequence would be: 1, 11, 21, 1211, 111221, ...
Q59. What is the process for writing a Bash script to read and parse a CSV file and print the last character of each line?
The process for writing a Bash script to read and parse a CSV file and print the last character of each line involves using a combination of commands and loops.
Use the 'while read' loop to read each line of the CSV file
Use 'awk' command to extract the last character of each line
Print the last character using 'echo' command
Q60. What is the SQL query to perform a join on two tables and calculate the aggregate sum using the product ID?
SQL query to perform a join on two tables and calculate aggregate sum using product ID.
Use JOIN keyword to combine two tables based on a related column (e.g. product ID)
Use GROUP BY clause to group the results by product ID
Use SUM() function to calculate the aggregate sum of a column (e.g. price)
Q61. What is the SQL query to join two tables and use aggregate functions such as SUM and AVG with GROUP BY?
SQL query to join two tables, use aggregate functions like SUM and AVG with GROUP BY
Use JOIN keyword to combine two tables based on a common column
Use GROUP BY clause to group the results based on a specific column
Use aggregate functions like SUM() and AVG() to calculate totals and averages within each group
Q62. Coding question: Implement Merge Sort
Merge Sort is a divide-and-conquer algorithm that recursively divides an array into two halves, sorts them, and then merges them.
Divide the array into two halves
Recursively sort each half
Merge the sorted halves
Functional Components are simple functions that take props as input and return JSX, while Class Components are ES6 classes that extend React.Component and have additional features like state and lifecycle methods.
Functional Components are simpler and easier to read/write compared to Class Components.
Functional Components do not have access to state or lifecycle methods, while Class Components do.
Functional Components are stateless, while Class Components can be stateful.
Funct...read more
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
Q66. 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.
Q67. 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.
Q68. Given an array of non-negative integers.Find the length of the longest subsequence such that elements in the subsequence are contiguous integers. The consecutive numbers can be in any order. Example n=7 nums={2...
read moreFind the length of the longest subsequence of contiguous integers in an array.
Sort the array
Iterate through the array and check for consecutive integers
Keep track of the longest subsequence found
Q69. Get list of pincodes from these objects Employee{ id Long, name String, Addresses : List } Addresses{ houseNo long, pindcode long, state String, country String, } Ans. Use flatMap to flatten and then use map to...
read moreUse flatMap and map to extract list of pincodes from Employee objects
Use flatMap to flatten the list of Addresses in each Employee object
Use map to iterate over the flattened list and extract the pincodes
Example: employeeList.stream().flatMap(emp -> emp.getAddresses().stream()).map(address -> address.getPincode()).collect(Collectors.toList())
Q70. What is Database Pooling, Hikari and its configurations. Java 8 to current enchancements and current java version Factory and Builder design patterns to explain and code Project expalantion and details, Cross q...
read moreDatabase pooling is a technique used to manage a pool of database connections for efficient resource utilization. HikariCP is a popular database connection pooling library in Java.
HikariCP is a high-performance database connection pooling library for Java applications.
It is known for its low latency and high throughput.
Configurations for HikariCP include settings such as maximum pool size, connection timeout, and idle timeout.
Example: HikariConfig config = new HikariConfig();...read more
Q71. What is method overriding
Method overriding is a feature in object-oriented programming where a subclass provides a specific implementation of a method that is already provided by its parent class.
Occurs when a subclass provides a specific implementation of a method that is already provided by its parent class
The method in the subclass must have the same name, return type, and parameters as the method in the parent class
Allows for polymorphism, where a subclass can be treated as an instance of its par...read more
Q72. What are the principles of Continuous Integration and Continuous Deployment (CI/CD)?
CI/CD is a software development practice where code changes are automatically built, tested, and deployed frequently.
Continuous Integration (CI) involves automatically integrating code changes into a shared repository multiple times a day.
Continuous Deployment (CD) involves automatically deploying code changes to production after passing automated tests.
CI/CD helps in detecting and fixing integration errors early, ensuring code quality, and enabling faster delivery of feature...read more
Q73. What version control tools do you use, and can you explain how you utilize them?
I primarily use Git for version control, utilizing branches, commits, and merges for collaboration and tracking changes.
Primary version control tool is Git
Utilize branches for different features or fixes
Regularly commit changes with descriptive messages
Merge branches to integrate changes
Use tools like GitHub or Bitbucket for collaboration
Q74. What is the Bash command to suppress all output and errors?
The Bash command to suppress all output and errors is 'command > /dev/null 2>&1'
Use '>' to redirect standard output to /dev/null
Use '2>&1' to redirect standard error to standard output
Combine both to suppress all output and errors: 'command > /dev/null 2>&1'
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
Q76. Code a system to query an API, do multiprocessing and improve the efficiency
Code a system to query an API, do multiprocessing and improve efficiency
Use a library like requests in Python to query the API
Implement multiprocessing using a library like multiprocessing or threading in Python
Optimize efficiency by caching API responses or using asynchronous programming
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.
Q78. Java core features and advantages
Java is a popular programming language known for its platform independence and object-oriented features.
Platform independence allows Java code to run on any platform without recompilation
Object-oriented features like encapsulation, inheritance, and polymorphism make code modular and reusable
Java has a vast standard library with built-in support for networking, I/O, and concurrency
Java is highly secure with features like bytecode verification and automatic memory management
Q79. Find the maximum for each and every contiguous subarray of size k from an arr of size n.
Find maximum for each contiguous subarray of size k from an array of size n.
Iterate through the array and keep track of maximum for each subarray of size k
Use a sliding window approach to efficiently calculate maximum for each subarray
Time complexity: O(n)
Example: arr = [10, 5, 2, 7, 1, 9, 4], k = 3, output = [10, 7, 7, 9, 9]
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.
Q81. Would it be acceptable to work shift timings from 6:30 AM to 3:30 PM considering that the client is based in New Zealand?
Yes, it would be acceptable to work shift timings from 6:30 AM to 3:30 PM for a client based in New Zealand.
Working from 6:30 AM to 3:30 PM would align with the standard working hours in New Zealand due to the time zone difference.
This shift timing would allow for better communication and collaboration with the client in New Zealand.
It is important to ensure that the team is able to adjust to the early start time and maintain productivity throughout the day.
Q82. How do you troubleshoot if a having internet issue?
To troubleshoot an internet issue, check the connection, restart the router, check for software issues, and contact the service provider if needed.
Check the physical connection of the router and modem
Restart the router and modem
Check for any software issues on the device (e.g. network settings, firewall)
Contact the internet service provider for further assistance
Q83. 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.
Q84. DBMS types and features known
DBMS types include relational, NoSQL, object-oriented, and hierarchical. Each has unique features and use cases.
Relational DBMS: structured data, ACID compliance, SQL queries (e.g. MySQL, Oracle)
NoSQL DBMS: unstructured data, flexible schema, horizontal scaling (e.g. MongoDB, Cassandra)
Object-oriented DBMS: data stored as objects, supports inheritance and polymorphism (e.g. db4o)
Hierarchical DBMS: data organized in a tree-like structure, good for storing nested data (e.g. IBM...read more
Q85. 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
Q86. Program to find repeating characters in a string
The program finds repeating characters in a given string.
Iterate through each character in the string
Store each character in a data structure
If a character is already present in the data structure, it is a repeating character
Q87. 1.Implement merge sort. 2. Kth largest element.
Implement merge sort and find kth largest element in an array.
Merge sort is a divide and conquer algorithm that recursively divides the array into two halves, sorts them and then merges them.
Kth largest element can be found using quick select algorithm or by sorting the array and returning the kth element from the end.
Merge sort has a time complexity of O(nlogn) and space complexity of O(n).
Quick select has a time complexity of O(n) in average case and O(n^2) in worst case.
So...read more
Q88. conditions for a deadlock
Conditions for a deadlock in software engineering
Deadlock occurs when each process in a set is waiting for an event that only another process in the set can cause
Four conditions for a deadlock: mutual exclusion, hold and wait, no preemption, circular wait
Example: Process A holds resource X and waits for resource Y, while Process B holds resource Y and waits for resource X
Q89. Types of props and their how do they work?
Props are inputs passed to React components. There are two types: ownProps and childrenProps.
ownProps are passed directly to the component from its parent
childrenProps are passed to the component through its children
ownProps can be accessed using this.props in the component
childrenProps can be accessed using this.props.children in the component
Q90. Design Patterns like Singleton and how to create them
Singleton is a creational design pattern that ensures a class has only one instance and provides a global point of access to it.
To create a Singleton, make the constructor private to prevent direct instantiation
Create a static method that returns the instance of the class
Use lazy initialization to create the instance only when it's needed
Ensure thread safety by using synchronized keyword or double-checked locking
Examples: java.lang.Runtime, java.awt.Desktop, java.util.Calenda...read more
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.
Q92. concets on oops
OOPs concepts are the fundamental principles of object-oriented programming.
Abstraction
Encapsulation
Inheritance
Polymorphism
Q93. What is the purpose of the @Primary and @Qualifier annotations in Spring Framework?
The @Primary annotation is used to give a higher priority to a bean when multiple beans of the same type are present. The @Qualifier annotation is used to specify which bean to inject when multiple beans of the same type are present.
Use @Primary annotation to specify the primary bean to be used when multiple beans of the same type are present.
Use @Qualifier annotation along with the bean name to specify which bean to inject when multiple beans of the same type are present.
Exa...read more
Q94. What are joins? How are they useful?
Joins are used to combine data from two or more tables based on a related column.
Joins are useful for retrieving data from multiple tables that have a relationship.
There are different types of joins such as inner join, left join, right join, and full outer join.
Inner join returns only the matching rows from both tables.
Left join returns all the rows from the left table and matching rows from the right table.
Right join returns all the rows from the right table and matching row...read more
Q95. Segregate an array containing 0 and 1 with minimum number of swaps.
Segregate an array of 0s and 1s with minimum swaps.
Count the number of 0s in the array.
Swap the 1s with the 0s until all 0s are on one side and 1s on the other.
The minimum number of swaps required is half the number of 1s on the side with fewer 1s.
Q96. How to find the Second highest salary from employees table. Write the logic for pre-order, inorder and post-order traversal of a binary tree
To find the second highest salary from employees table and traverse a binary tree in pre-order, in-order, and post-order.
To find the second highest salary, you can use a subquery or window function like ROW_NUMBER() or DENSE_RANK().
For pre-order traversal, visit the root node first, then recursively do a pre-order traversal of the left subtree, followed by the right subtree.
For in-order traversal, recursively do an in-order traversal of the left subtree, visit the root node, ...read more
Q97. What is Singleton design pattern.
Singleton design pattern restricts the instantiation of a class to one object.
Ensures only one instance of a class exists
Provides a global point of access to that instance
Used when only one instance of a class is needed throughout the application
Example: Database connection manager
Q98. Explain Automation framework that u suggest to automate amazon application
I suggest using a hybrid automation framework for testing Amazon application.
Use Selenium WebDriver for web automation
Use Appium for mobile automation
Use TestNG for test management and reporting
Use Page Object Model for better code maintenance
Use data-driven approach for test data management
Use Jenkins for continuous integration and deployment
Q99. How did you implement multithreading in your project?
Implemented multithreading using Java's Thread class and Executor framework.
Used Thread class to create and manage threads.
Utilized Executor framework for managing thread pools and executing tasks.
Implemented synchronization mechanisms like locks and semaphores to prevent race conditions.
Used Java's concurrent data structures like ConcurrentHashMap and BlockingQueue for thread-safe operations.
Q100. What is the concept of lock isolation in Spring Framework?
Lock isolation in Spring Framework ensures that each transaction operates independently without interfering with other transactions.
Lock isolation prevents concurrent transactions from affecting each other's data.
Different levels of lock isolation can be set in Spring, such as READ_COMMITTED and REPEATABLE_READ.
For example, setting a higher level of lock isolation like REPEATABLE_READ ensures that a transaction will not see changes made by other transactions until it is compl...read more
Top HR Questions asked in Bounteous x Accolite
Interview Process at Bounteous x Accolite

Top Interview Questions from Similar Companies






Reviews
Interviews
Salaries
Users/Month