Search⌘ K
AI Features

Feature #4: Milestone Reached

Understand how to identify the exact day and week a stockbroker achieves a milestone by applying binary search to a 2D matrix of cumulative trade records. This lesson helps you implement a method to map matrix indices to linear array positions and efficiently find target values in sorted data, optimizing both time and space complexity.

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

...