Tower Research Capital LLC
Amazon 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. 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
Q3. 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()
Q5. "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
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
More about working at Tower Research Capital LLC
Top Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month