Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Value of Covered Indices

Maximum Total Value of Covered Indices gives an array and binary string marking tokens. Keep each token or shift it left once, avoiding collisions, to maximize the sum of covered values.

Statement

You are given an integer array nums and a binary string s, both of length n.

A token is initially located at index i if s[i] == '1'. For each token at index i, you may choose one of the following actions:

  • Keep the token at index i.

  • Shift the token to index i−1i - 1, provided that i>0i > 0.

At most one token can occupy any index after all choices are made.

Return the maximum possible sum of nums[j] across all indices j covered by a token.

Constraints:

  • 1≤1 \leq n ==== nums.length ==== s.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • s[i] is either '0' or '1'

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Total Value of Covered Indices

Maximum Total Value of Covered Indices gives an array and binary string marking tokens. Keep each token or shift it left once, avoiding collisions, to maximize the sum of covered values.

Statement

You are given an integer array nums and a binary string s, both of length n.

A token is initially located at index i if s[i] == '1'. For each token at index i, you may choose one of the following actions:

  • Keep the token at index i.

  • Shift the token to index i−1i - 1, provided that i>0i > 0.

At most one token can occupy any index after all choices are made.

Return the maximum possible sum of nums[j] across all indices j covered by a token.

Constraints:

  • 1≤1 \leq n ==== nums.length ==== s.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • s[i] is either '0' or '1'