Katkat

Implement drawdown, single-trade profit, coin change

SquarepointData Scientist · Technical Screen

Last updated

This question evaluates a candidate's algorithmic problem-solving skills across array and time-series processing, greedy optimization, and dynamic programming, requiring implementation and complexity analysis of maximum drawdown, single-trade profit, and coin change problems within the Coding & Algorithms domain for a Data Scientist role.

Implement and analyze the following three problems:

  1. Maximum drawdown of cumulative PnL: "What is the maximum drawdown of a cumulative PnL (profit and loss) series, and when did it occur?" Write mdd(pnl) that returns: (a) the maximum drawdown as a negative number; (b) the start index (just after the peak before the drawdown starts); and (c) the end index (where the maximum drawdown ends). State time and space complexity.
  2. Single-trade stock profit (LeetCode-inspired): Given an integer array prices where prices[i] is the price on day i, compute the largest profit achievable by buying once and selling on a later day. If no profitable trade exists, return 0. Design an O (n) time, O(
  3. space solution and explain the intuition.
  4. Minimum coins for target amount (LeetCode-inspired): Given coin denominations coins and a target amount, return the smallest number of coins needed to reach the target, or -1 if it cannot be formed. Assume unlimited coins of each type. Provide a dynamic programming approach and analyze time and space.