Future Stock Prices
Updated
Problem statement
Given an unordered list of future stock prices, what is the maximum amount of profit that you could generate from a starting amount of $1,000.00
Rules:
- You can trade fractional shares (e.g. if there were shares for $400.00, you could buy/sell 2.5 of them for $1,000.00)
- All trades occur instantaneously and do not incur any transaction costs.
- Shares may only be bought/sold on a date that you have a known price.
- Short selling is not allowed.
- You do not need to have a position at all times (at any time, if you cannot identify a profitable trade, you do not have to trade).
- Round final answer to nearest dollar.
- Do not assume input tuple will be sorted in any manner.
- Future prices will be given as a list in the following format: [Stock, Date, Price]
Function
maximumProfit(prices: String[]) → intExamples
Example 1
prices = ["CSCO,10/18/2024,41.89", "AMZN,10/10/2024,113.67", "AMZN,10/18/2024,120.5", "CSCO,10/10/2024,43.12"]return = 60Buy 8.797 AMZN @ $113.67 on 10/10/2024 and sell @ $120.5 on 10/18/2024. Profit = $60
Example 2
prices = ["IBM,12/01/2023,132.05", "IBM,12/03/2023,135.19", "IBM,12/18/2023,134.07", "AAPL,12/01/2023,187.19", "AAPL,12/04/2023,164.33", "AAPL,12/20/2023,180.94", "AAPL,12/21/2023,179.65", "GOOG,12/01/2023,116.41", "GOOG,12/07/2023,111.36", "GOOG,12/19/2023,112.19"]return = 127Buy 7.573 IBM @ $132.05 on 12/01/2023 and sell @ $135.19 on 12/3/2023. Buy 6.230 AAPL on 12/4/2023 @ $164.33 and sell on 12/20/2023 @ $180.94. Profit = $127
More Akuna Capital interview questions
- Last Digit of the Ways to Split Traders Between Two OfficesOA · Seen Dec 2026
- Light Bulbs Left On After All Engineers FinishOA · Seen Dec 2026
- Delivery Management SystemOA · Seen Nov 2026
- Count Server ReplacementsOA · Seen Nov 2026
- Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Maximum Remaining Drone PowerOA · Seen Nov 2026
- Biased Coin: Probability of Exactly h HeadsPHONE SCREEN · Seen Nov 2026
- Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Rolling MetricsOA · Seen Oct 2026
- Vowel Substring GameOA · Seen Sep 2026
Similar questions at other companies
- Hiking Club Fastest PaceInfosys · OAInfosys interview questions
- Find Minimum TimeAlphaSense · OA
- Find Minimum TimeBlackRock · OABlackRock interview questions
- Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
- Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
- Minimum Cost of Every K-Capable Model SetTikTok · OATikTok interview questions
- Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
- Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
- Maximize Minimum Deployment DifficultyJP Morgan Chase · OAJP Morgan Chase interview questions
Akuna Capital interview experiences
- Akuna Capital Quant Trader and QR Interviews: 5 Experiences
- Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
- Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
- Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
- Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
- Akuna Capital QR Coding Interviews: 17 Experiences (Part 2 of 6)