
Tower Research Capital LLC

30+ Tower Research Capital LLC Interview Questions and Answers
Q1. Best Time to Buy and Sell Stock Problem Statement
Given an array prices
representing the prices of a stock where each element indicates the price at a given minute, determine the maximum profit you can achieve ...read more
Find the maximum profit by buying and selling a stock once based on given prices.
Iterate through the prices array and keep track of the minimum price seen so far and the maximum profit achievable.
Calculate the profit by subtracting the current price from the minimum price and update the maximum profit if needed.
Return the maximum profit, ensuring it is not negative.
Example: prices = [2, 100, 150, 120], Buy at 2, sell at 150, profit = 150 - 2 = 148.
Q2. Print Nodes at Distance K from a Given Node
Given an arbitrary binary tree, a node of the tree, and an integer 'K', find all nodes that are at a distance K from the specified node, and return a list of these no...read more
Given a binary tree, a target node, and an integer K, find all nodes at distance K from the target node.
Traverse the binary tree to find the target node.
Use BFS to traverse the tree from the target node to nodes at distance K.
Keep track of the distance while traversing the tree.
Return the values of nodes at distance K in any order.
Q3. Dance Team Pairing Challenge
Imagine you are helping Ninja, a dance coach, who needs to form dance pairs from the available boys and girls in a studio. Given the number of boys N
, the number of girls M
, and the...read more
The challenge involves forming dance pairs from available boys and girls based on potential pairings to maximize the number of pairs.
Parse the input to get the number of test cases, boys, girls, and potential pairings.
Iterate through the potential pairings and form pairs based on the given indexes.
Output '1' if a set of maximum possible pairs is returned, else output '0'.
There can be multiple valid configurations of pairs.
Example: For input '2 2 2' and pairings '1 1' and '2 2...read more
Q4. A group of n people is such that a symmetric relation of knowing another exists in the group. i.e. the relation is A knows B. and being symmetric if A knows B then B knows A. Prove that there exist atleast 2 pe...
read moreIn a group of people with a symmetric relation of knowing each other, there will always be at least two people who know the same number of people.
Consider the person who knows the maximum number of people in the group.
If there is no one who knows the same number of people, then everyone else must know a different number of people.
But this would mean that the total number of people known by everyone else is different from the total number of people known by the person who know...read more
Q5. Unweighted Graph Shortest Path Problem
You are tasked with finding the shortest path between two houses in the city of Ninjaland, represented as an unweighted graph. The city has N
houses numbered from 1 to N
a...read more
Find the shortest path between two houses in a city represented as an unweighted graph.
Use breadth-first search (BFS) algorithm to find the shortest path in an unweighted graph.
Start BFS from the source house and keep track of the path taken to reach each house.
Once the destination house is reached, backtrack from destination to source to find the shortest path.
Consider using a queue data structure to implement BFS efficiently.
Handle cases where multiple shortest paths exist ...read more
Q6. Clearing the Forest Problem Statement
Ninja lives in a city called Byteland where a festive event is being organized. To make space for this event, Ninja is tasked with clearing a nearby forest. The forest is r...read more
Calculate the minimum number of steps Ninja needs to cut down all trees in a forest grid.
Iterate through the grid to find the shortest path to cut down all trees in order.
Use a priority queue to keep track of the shortest trees to cut next.
If it's impossible to cut all trees, return -1.
Consider all four cardinal directions for movement in the grid.
Q7. Consider the set S of the first 2n numbers, then show that for any subset of size n+1 of the set S, there exists 2 numbers u and v such that u divides v
For any subset of size n+1 of the set S of the first 2n numbers, there exists 2 numbers u and v such that u divides v.
Divide the set S into two subsets of n numbers each.
By the pigeonhole principle, at least one of the subsets contains two numbers whose ratio is an integer.
If the subset contains n+1 numbers, then one of the numbers must be in the subset with the two numbers whose ratio is an integer.
Therefore, there exists 2 numbers u and v such that u divides v.
Q8. There were 7 guests at a party + a host. 1st guest shook hands with 1 guy, 2nd guest with 2 guys .... kth guest with k guys. How many people did the host shake hands with? k was either 6 or 7, probably 7 – I do...
read moreAt a party with 7 guests and a host, each guest shakes hands with a certain number of people. How many people did the host shake hands with?
The first guest shakes hands with 1 person, the second with 2 people, and so on.
The kth guest shakes hands with k people.
The host shakes hands with all 7 guests, so the number of people the host shakes hands with is the sum of 1 to 7.
The sum of 1 to n is n(n+1)/2, so the host shakes hands with 28 people.
Q9. Palindromic Substrings Problem Statement
Given a string S
, your task is to return all distinct palindromic substrings of the given string in alphabetical order.
Explanation:
A string is considered a palindrome ...read more
Return all distinct palindromic substrings of a given string in alphabetical order.
Iterate through all possible substrings of the given string.
Check if each substring is a palindrome by comparing it with its reverse.
Store all palindromic substrings in a set to ensure uniqueness.
Return the sorted list of palindromic substrings.
Q10. Rearrange Array Numbers for Largest Possible Number
Given an array ARR
consisting of non-negative integers, rearrange the numbers to form the largest possible numerical value. You are not permitted to alter the...read more
Rearrange array numbers to form the largest possible numerical value by combining digits of each number in the array.
Convert integers in the array to strings for easier manipulation.
Sort the array of strings in non-increasing order based on custom comparison function.
Join the sorted strings to form the largest possible number.
Q11. In a city represented as a 2-D plane there are buildings at different positions. The position of the buildings(x,y co-ordinates) and their heights are given. Write an efficient algorithm to determine the buildi...
read moreAlgorithm to determine visible buildings in a 2D plane with given positions and heights
Sort the buildings by their x-coordinates
Traverse the sorted buildings from left to right
For each building, check if it is visible by comparing its height with the maximum height of previously visited buildings
If visible, add it to the list of visible buildings
Return the list of visible buildings
Q12. Minimum Cost to Reduce Array
Given an array ARR
of size N
containing positive integers, the task is to reduce the size of the array to 1 by performing a specific operation multiple times. In one operation, you ...read more
Find the minimum cost to reduce an array to one element by merging adjacent elements.
Iterate through the array and merge adjacent elements with the smallest sum each time.
Keep track of the total cost as you merge elements.
Repeat the merging process until only one element remains in the array.
Q13. Check If Two Nodes Are Cousins
You are given an arbitrary binary tree consisting of N nodes, where each node is associated with a certain value, and two node values, a
and b
. Your task is to determine if these ...read more
Check if two nodes in a binary tree are cousins by comparing their levels and parents.
Traverse the tree to find the levels and parents of the given nodes.
Compare the levels and parents of the two nodes to determine if they are cousins.
If the levels are the same and the parents are different, the nodes are cousins.
Q14. Counting Nodes in a Complete Binary Tree - Problem Statement
Given the root of a complete binary tree, calculate the total number of nodes in this tree.
A complete binary tree is defined as a binary tree in whi...read more
Count the total number of nodes in a complete binary tree given its root.
Traverse the tree in level order and count the nodes
Use a queue to keep track of nodes at each level
Check for null nodes represented by -1 in the input
The total number of nodes in the example tree is 7
Q15. Subarray Challenge: Largest Equal 0s and 1s
Determine the length of the largest subarray within a given array of 0s and 1s, such that the subarray contains an equal number of 0s and 1s.
Input:
Input begins with...read more
Find the length of the largest subarray with equal number of 0s and 1s in a given array.
Iterate through the array and maintain a count of 0s and 1s encountered so far.
Store the count difference in a hashmap with the index as the key.
If the same count difference is encountered again, the subarray between the two indices has equal 0s and 1s.
Return the length of the longest subarray found.
Q16. Word Ladder Problem Statement
Given two strings, BEGIN
and END
, along with an array of strings DICT
, determine the length of the shortest transformation sequence from BEGIN
to END
. Each transformation involves ...read more
The Word Ladder problem involves finding the shortest transformation sequence from one word to another by changing one letter at a time.
Use breadth-first search to find the shortest transformation sequence.
Create a graph where each word is a node and edges connect words that differ by one letter.
Keep track of visited words to avoid revisiting them.
Return -1 if no transformation sequence is possible.
Q17. Number of Islands Problem Statement
You are provided with a 2-dimensional matrix having N
rows and M
columns, containing only 1s (land) and 0s (water). Your goal is to determine the number of islands in this ma...read more
Count the number of islands in a 2D matrix of 1s and 0s.
Use Depth First Search (DFS) or Breadth First Search (BFS) to traverse the matrix and identify connected groups of 1s.
Maintain a visited array to keep track of visited cells to avoid redundant traversal.
Increment the island count whenever a new island is encountered.
Consider all eight possible directions for connectivity between cells.
Handle edge cases like out of bounds indices and already visited cells.
Q18. Given an undirected graph, if dist(u,v)>n/2. Show that there exists a vertex x such that removing x makes u and v go to different connected components.
If dist(u,v)>n/2 in an undirected graph, there exists a vertex x such that removing x makes u and v go to different connected components.
Find the shortest path between u and v
If the path length is greater than n/2, then there must be a vertex x on the path
Removing x will separate u and v into different connected components
Q19. Given a string, find the largest substring which can be formed from repetition (>=2) of the smaller string
Find the largest substring formed from repetition of a smaller string.
Identify all possible substrings of the given string.
Check if each substring can be formed by repeating a smaller string.
Return the largest substring that can be formed from repetition of a smaller string.
Q20. Island Perimeter Calculation Problem
Given a binary grid representation of a map of an island, calculate the perimeter of the island. The grid uses '0' for water and '1' for land.
The grid has only one island, ...read more
Calculate the perimeter of an island represented by a binary grid.
Iterate through the grid and count the perimeter based on land cells and their adjacent cells.
Each land cell contributes 4 units to the perimeter, subtract 2 units for each adjacent land cell.
Handle edge cases where land cells are at the boundaries of the grid.
Return the total perimeter for each test case.
Q21. 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 it
If any fresh oranges remain after simulation, return -1
Handle edge cases like empty grid or no fresh oranges
Q22. Show that for a grid of size n*n, if n is odd then there cannot be a Hamiltonian cycle in the graph
For an odd-sized grid, there cannot be a Hamiltonian cycle in the graph.
A Hamiltonian cycle is a path that visits every vertex exactly once and ends at the starting vertex.
In an n*n grid, there are n^2 vertices and each vertex has degree 4.
For an odd n, the total degree of all vertices is odd, which means there cannot be a Hamiltonian cycle.
Q23. Prove that F_nk is divisible by F_n where F_i is the ith Fibonacci number. with f_0 = 0
Prove that F_nk is divisible by F_n where F_i is the ith Fibonacci number. with f_0 = 0
Use mathematical induction to prove the statement
Base case: F_n0 = 0, F_n is also 0, so 0 is divisible by 0
Inductive step: Assume F_nk is divisible by F_n, prove F_n(k+1) is divisible by F_n
F_n(k+1) = F_nk + F_n(k-1), use the assumption to show that F_nk is divisible by F_n
Therefore, F_n(k+1) is also divisible by F_n
Hence, the statement is true for all k
Q24. In a 2 D plane, every point is assigned a color either blue or red. Prove that there exists a rectangle with all corners of the same color
Prove that there exists a rectangle with all corners of the same color in a 2D plane with blue and red points.
Divide the plane into a grid of squares.
By the pigeonhole principle, there must be at least one row or column with four points of the same color.
Consider the pairs of points in that row or column and check if any of them form a rectangle.
Q25. The Red-Blue Hat Prisoners puzzle: if prisoner guesses colour of his hat he lives else dies. Idea is to save as many prisoners as possible. Actual solution saves n-1 prisoners but I hadn’t heard this puzzle bef...
read moreSolution to Red-Blue Hat Prisoners puzzle that saves n - log(n) prisoners.
Red-Blue Hat Prisoners puzzle involves prisoners guessing the color of their own hat to save their lives.
The actual solution saves n-1 prisoners, but there are alternative solutions that can save more prisoners.
One such solution involves using binary encoding to communicate the color of the hats, which can save n - log(n) prisoners.
This solution works by having each prisoner encode the color of their ha...read more
Q26. Given a unit circle with center at origin, I choose three points on the circle. Find the expected length of the segment containing (1.0). Hint: answer is not 2*pi/3
Expected length of segment containing (1,0) on a unit circle with three random points.
Use law of cosines to find length of each segment.
Calculate expected value using probability density function.
Answer is (4/pi) + (2/3).
Q27. Given k and DFS traversal string for a k-ary tree, construct the tree. The String contains P (if a parent) and L (if a leaf). E.g. - k=3, str="PPLLLLL" 2. All the strings are arranged in the following order: A,...
read moreThe question asks to construct a k-ary tree using the given k and DFS traversal string.
Iterate through the DFS traversal string
If the current character is 'P', create a parent node
If the current character is 'L', create a leaf node
Link the nodes according to the DFS traversal order
Splitwise is a system for managing shared expenses among groups of people.
Classes: User, Expense, Group
Functions: addExpense(), settleUp(), calculateBalance()
ACID properties ensure database transactions are processed reliably. Rollback mechanism undoes changes if transaction fails.
ACID properties: Atomicity, Consistency, Isolation, Durability
Atomicity ensures all operations in a transaction are completed successfully or none at all
Consistency ensures database remains in a valid state before and after transaction
Isolation ensures transactions are independent and do not interfere with each other
Durability ensures changes made by com...read more
Output the person with the maximum earnings from each department
Join the employee and department tables on department ID
Group by department ID and find the max earnings for each department
Join the result with the employee table to get the person with max earnings
Q31. "How would you tell whether a graph has a node with n degree?"
To determine if a graph has a node with n degree, iterate through all nodes and count their edges.
Iterate through each node in the graph
Count the number of edges connected to each node
If any node has n edges, then the graph has a node with n degree
To find and correct a bug in code, analyze problem statement, review code, use debugging tools, and test different scenarios.
Understand the problem statement and expected output.
Review the code for syntax errors, logical errors, and potential bugs.
Use debugging tools like breakpoints, print statements, and IDE debuggers.
Test the code with different inputs to identify the bug.
Make necessary corrections based on the identified bug.
Re-test the code to ensure the bug is fixed.
Multiprocessing involves multiple processes running concurrently, while multithreading involves multiple threads within a single process.
Multiprocessing utilizes multiple processes to execute tasks simultaneously.
Multithreading involves multiple threads within a single process sharing the same memory space.
Multiprocessing is typically used for CPU-bound tasks, while multithreading is more suitable for I/O-bound tasks.
Example: Running multiple instances of a web server on diff...read more
Splitwise is a system for managing shared expenses among groups of people.
1. Allow users to create groups and add members to track shared expenses.
2. Implement features for adding expenses, specifying who paid and who owes.
3. Calculate balances for each member and settle debts efficiently.
4. Provide notifications and reminders for pending payments.
5. Ensure security and privacy of user data.
6. Implement features like expense categorization, comments, and attachments.
7. Allow ...read more
Q35. Would you prefer to develop mathematical models or to develop the trading infrastructure?
I would prefer to develop mathematical models.
I enjoy the process of creating and testing mathematical models.
Developing trading infrastructure is important, but not my primary interest.
Mathematical models can be applied to various industries, not just trading.
Examples of mathematical models I have developed include predictive models for customer behavior and financial forecasting models.
Q36. Check if a string containing parenthesis is balanced
Check if a string containing parenthesis is balanced
Use a stack to keep track of opening parenthesis
Iterate through the string and push opening parenthesis onto the stack
If a closing parenthesis is encountered, check if the stack is empty or if the top of the stack is the corresponding opening parenthesis
If the stack is empty or the top of the stack doesn't match, the string is not balanced
After iterating through the string, if the stack is empty, the string is balanced
Q37. Check if a graph has a unique Topological sort
A graph has a unique topological sort if and only if it is a directed acyclic graph (DAG).
A topological sort is a linear ordering of the vertices of a graph such that for every directed edge (u, v), vertex u comes before vertex v in the ordering.
To check if a graph has a unique topological sort, we can use depth-first search (DFS) or breadth-first search (BFS) algorithms.
If during the DFS or BFS traversal, we encounter a back edge or a cycle, then the graph does not have a un...read more
Q38. Explaining incidents faced
I have faced incidents related to system crashes, network failures, and security breaches.
System crash due to hardware failure
Network failure due to misconfiguration
Security breach due to weak password policy
DDoS attack causing website downtime
Q39. Design MakeMyTrip kind of application.
MakeMyTrip is a travel booking application that allows users to book flights, hotels, and holiday packages.
Include features like flight/hotel search, booking, payment gateway integration, and user profiles.
Implement filters for search results, reviews/ratings for hotels, and notifications for booking updates.
Integrate maps for location tracking, weather forecasts, and customer support chatbot.
Offer discounts, loyalty programs, and referral bonuses to attract and retain custom...read more
More about working at Tower Research Capital LLC

Top HR Questions asked in Tower Research Capital LLC
Interview Process at Tower Research Capital LLC

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

