Trains the technique from
LeetCode 2643Row With Maximum OnesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A punch sheet is recorded as a grid sheet of 0s and 1s, where sheet[r][c] is 1 when the cell in row r and column c has been punched and 0 when it has not. Every row of the sheet has the same number of columns.
Find the row that holds the most punched cells. If several rows hold the same number of punched cells, and that is the most, take the one with the smallest row index.
Return a two-entry array [row, punches], where row is the index of that row and punches is how many punched cells it holds.
Example 1
The rows hold 2, 1 and 3 punched cells, so row 2 with its 3 punches is reported.
Example 2
Rows 0 and 2 both hold 2 punched cells and row 1 holds 1. The tie between rows 0 and 2 goes to the smaller index.
Example 3
Nothing is punched, so every row holds 0 and the smallest index wins the tie.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def busiest_row(sheet: list[list[int]]) -> list[int]:public int[] busiestRow(int[][] sheet)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.