#3542

Minimum Operations to Convert All Elements to Zero

specialist · 830 · lc medium +31 · 53% accepted · 613 likes · top 44%

Description

Given non-negative integer array nums, zero out the entire array in as few operations as possible. Each operation chooses a subarray and sets every occurrence of that subarray\'s minimum (non-negative) value to 0.

Return the minimum number of operations needed.

Code

1
2
3