Search⌘ K
AI Features

Feature #4: Milestone Reached

Understand how to determine the exact day and week a stockbroker reached a milestone of trades by applying binary search to a matrix of cumulative trading data. This lesson guides you through mapping a 2D matrix to a linear structure for efficient searching and implementing an optimized solution with clear time and space complexity analysis.

Description

Our company wants to display high achieving brokers in a hall of fame. They want to find out if a broker reached a milestone of making k trades and, if so, they want to know when they reached that milestone. Stockbrokers have been making trades and recording their tally of completed trades since the start of their career at the company. The data is being recorded into separate log files, each of which can be viewed as a matrix with 5 columns, one for each day of the week. There are r rows, representing the last r weeks of the year. We want to find out when a given broker reached the milestone of k trades in their career.

We’ll be provided with an m x 5 matrix and a target milestone value. Our task is to determine the day and week a stockbroker fulfilled their milestone.

Solution

...