Tap here to switch tabs
Problem
Submissions

Problem: Construct the Longest New String

med
30 min
Try to solve the Construct the Longest New String problem.

Statement

You are given three integers x, y, and z.

You have:

  • x strings equal to "AA"

  • y strings equal to "BB"

  • z strings equal to "AB"

You want to concatenate a subset of these strings to create the longest possible string such that it does not contain "AAA" or "BBB" as a substring.

Return the maximum possible length of the resulting string.

Constraints:

  • 1≤1 \leq x, y, z ≤50\leq 50

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Construct the Longest New String

med
30 min
Try to solve the Construct the Longest New String problem.

Statement

You are given three integers x, y, and z.

You have:

  • x strings equal to "AA"

  • y strings equal to "BB"

  • z strings equal to "AB"

You want to concatenate a subset of these strings to create the longest possible string such that it does not contain "AAA" or "BBB" as a substring.

Return the maximum possible length of the resulting string.

Constraints:

  • 1≤1 \leq x, y, z ≤50\leq 50