CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes561downloads
1{2    "id": 2850,3    "name": "construct_the_longest_new_string",4    "difficulty": "Medium",5    "link": "https://leetcode.com/problems/construct-the-longest-new-string/",6    "date": "2023-06-10 00:00:00",7    "task_description": "You are given three integers `x`, `y`, and `z`. You have `x` strings equal to `\"AA\"`, `y` strings equal to `\"BB\"`, and `z` strings equal to `\"AB\"`. You want to choose some (possibly all or none) of these strings and concatenate them in some order to form a new string. This new string must not contain `\"AAA\"` or `\"BBB\"` as a substring. Return _the maximum possible length of the new string_. A substring is a contiguous **non-empty** sequence of characters within a string. **Example 1:** ``` **Input:** x = 2, y = 5, z = 1 **Output:** 12 **Explanation: **We can concatenate the strings \"BB\", \"AA\", \"BB\", \"AA\", \"BB\", and \"AB\" in that order. Then, our new string is \"BBAABBAABBAB\". That string has length 12, and we can show that it is impossible to construct a string of longer length. ``` **Example 2:** ``` **Input:** x = 3, y = 2, z = 2 **Output:** 14 **Explanation:** We can concatenate the strings \"AB\", \"AB\", \"AA\", \"BB\", \"AA\", \"BB\", and \"AA\" in that order. Then, our new string is \"ABABAABBAABBAA\". That string has length 14, and we can show that it is impossible to construct a string of longer length. ``` **Constraints:** `1 <= x, y, z <= 50`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "x = 2, y = 5, z = 1",12            "output": "12 "13        },14        {15            "label": "Example 2",16            "input": "x = 3, y = 2, z = 2",17            "output": "14 "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                36,24                18,25                1326            ],27            "output": 10028        },29        {30            "input": [31                48,32                31,33                534            ],35            "output": 13636        },37        {38            "input": [39                46,40                17,41                2842            ],43            "output": 12644        },45        {46            "input": [47                3,48                24,49                1850            ],51            "output": 5052        },53        {54            "input": [55                17,56                30,57                1758            ],59            "output": 10460        },61        {62            "input": [63                4,64                40,65                2866            ],67            "output": 7468        },69        {70            "input": [71                4,72                35,73                2574            ],75            "output": 6876        },77        {78            "input": [79                34,80                17,81                3282            ],83            "output": 13484        },85        {86            "input": [87                32,88                11,89                1790            ],91            "output": 8092        },93        {94            "input": [95                44,96                42,97                3098            ],99            "output": 230100        }101    ],102    "haskell_template": "longestString :: Int -> Int -> Int -> Int\nlongestString x y z ",103    "ocaml_template": "let longestString (x: int) (y: int) (z: int) : int =  ",104    "scala_template": "def longestString(x: Int,y: Int,z: Int): Int = { \n    \n}",105    "java_template": "class Solution {\n    public int longestString(int x, int y, int z) {\n        \n    }\n}",106    "python_template": "class Solution(object):\n    def longestString(self, x, y, z):\n        \"\"\"\n        :type x: int\n        :type y: int\n        :type z: int\n        :rtype: int\n        \"\"\"\n        "107}