BackmediumUncategorized uncategorized medium

Max Mineral Diversity Solution

Problem Statement

Given a 2D binary matrix `minerals` of size `m x n`, find the indices of the rows that contain the most diverse range of minerals. The diversity of a row is calculated by counting the number of unique minerals it contains.

Example 1
Input
[[0, 1, 0], [1, 0, 0], [0, 0, 1], [0, 0, 1]]
Output
[0,1,2,3]

Explanation: The first and fourth rows contain the most diverse range of minerals.

Constraints

  • The input matrix `minerals` is a 2D binary matrix of size `m x n`.
  • The number of rows `m` can be greater than or equal to 1.
  • The number of columns `n` can be greater than or equal to 1.
  • The input matrix `minerals` will only contain numbers 0 and 1.
  • The output will be a list of indices representing the rows that contain the most diverse range of minerals.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free