Ctrl K

The Dimmest Rows

Easy
A light board is a matrix panel of m rows with n bulbs each: 1 means the bulb is on, 0 means it is off. In every row bulbs light up from left to right, so all ones come before all zeros. Row i is dimmer than row j if it has fewer bulbs on, or, with the same number on, if i < j. Return the indices of the count dimmest rows, ordered from dimmest to brightest.
Example 1
panel=[[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 0, 0], [1, 0, 0, 0]], count=3 → [1, 3, 2]

The rows have 3, 1, 2 and 1 lit bulbs. The dimmest are rows 1 and 3 (one each, smaller index first), then row 2.

Example 2
panel=[[0, 0], [1, 1], [0, 0]], count=2 → [0, 2]

Rows 0 and 2 are completely dark, and row 0 comes first by index.

Constraints
  • 2 ≤ m, n ≤ 100
  • 1 ≤ count ≤ m
  • panel[i][j] is 0 or 1
  • In each row all ones come before all zeros
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsK-th Smallest in a Sorted Grid MediumPeel Off the Row Maximums EasyNearest k Values MediumCrossing at High Tide HardRanked Prime Ratios Medium
loading Python…
Input
panel=[[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 0, 0], [1, 0, 0, 0]], count=3
Expected
[1, 3, 2]

Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.