#3117

Minimum Sum of Values by Dividing Array

international master · 2035 · lc hard +32 · 27.9% accepted · 143 likes · top 6%

Description

Given arrays nums (length n) and andValues (length m), partition nums into exactly m contiguous subarrays so the bitwise AND of the i-th subarray equals andValues[i]. The value of a subarray is its last element. Return the minimum total value across all subarrays, or -1 if no valid partition exists.

Code

1
2
3