CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes305downloads
1{2    "id": 2372,3    "name": "rearrange_characters_to_make_target_string",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/rearrange-characters-to-make-target-string/",6    "date": "2022-05-22 00:00:00",7    "task_description": "You are given two **0-indexed** strings `s` and `target`. You can take some letters from `s` and rearrange them to form new strings. Return_ the **maximum** number of copies of _`target`_ that can be formed by taking letters from _`s`_ and rearranging them._ **Example 1:** ``` **Input:** s = \"ilovecodingonleetcode\", target = \"code\" **Output:** 2 **Explanation:** For the first copy of \"code\", take the letters at indices 4, 5, 6, and 7. For the second copy of \"code\", take the letters at indices 17, 18, 19, and 20. The strings that are formed are \"ecod\" and \"code\" which can both be rearranged into \"code\". We can make at most two copies of \"code\", so we return 2. ``` **Example 2:** ``` **Input:** s = \"abcba\", target = \"abc\" **Output:** 1 **Explanation:** We can make one copy of \"abc\" by taking the letters at indices 0, 1, and 2. We can make at most one copy of \"abc\", so we return 1. Note that while there is an extra 'a' and 'b' at indices 3 and 4, we cannot reuse the letter 'c' at index 2, so we cannot make a second copy of \"abc\". ``` **Example 3:** ``` **Input:** s = \"abbaccaddaeea\", target = \"aaaaa\" **Output:** 1 **Explanation:** We can make one copy of \"aaaaa\" by taking the letters at indices 0, 3, 6, 9, and 12. We can make at most one copy of \"aaaaa\", so we return 1. ``` **Constraints:** `1 <= s.length <= 100` `1 <= target.length <= 10` `s` and `target` consist of lowercase English letters. **Note:** This question is the same as 1189: Maximum Number of Balloons.",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "s = \"ilovecodingonleetcode\", target = \"code\"",12            "output": "2 "13        },14        {15            "label": "Example 2",16            "input": "s = \"abcba\", target = \"abc\"",17            "output": "1 "18        },19        {20            "label": "Example 3",21            "input": "s = \"abbaccaddaeea\", target = \"aaaaa\"",22            "output": "1 "23        }24    ],25    "private_test_cases": [26        {27            "input": [28                "\"kyxgiwvrwffuuocuvxwgr\"",29                "\"yrxgcox\""30            ],31            "output": 132        },33        {34            "input": [35                "\"wpkniqtcjspwkzuhdhynlkaaymqqfanpyuvbzhhgriyikhmaxyq\"",36                "\"ai\""37            ],38            "output": 339        },40        {41            "input": [42                "\"zbrkcdleasuqgfuzghcefejvfzjyjyjdcetlmvvwzqjrtimabdkpnwakihdzacwoaterdoxtdzetwsoycccw\"",43                "\"zay\""44            ],45            "output": 346        },47        {48            "input": [49                "\"bk\"",50                "\"bkkbb\""51            ],52            "output": 053        },54        {55            "input": [56                "\"xnvhtafmjzmpsypqvs\"",57                "\"qxyvynmv\""58            ],59            "output": 060        },61        {62            "input": [63                "\"dxdaxgciwfdbcnhxxfbtrdunqtchstmnheoknsoykzedmhtiuwqfeivdkdaubmhobfvrfkxesylyelacog\"",64                "\"w\""65            ],66            "output": 267        },68        {69            "input": [70                "\"cwjiywhsoifvkfxuhkjabliwyqsbqzdhnnvszqskdxmfpzquqejzjwqofrlfdafkdnffbyiapoodpxqah\"",71                "\"zksszo\""72            ],73            "output": 274        }75    ],76    "haskell_template": "rearrangeCharacters :: String -> String -> Int\nrearrangeCharacters s target ",77    "ocaml_template": "let rearrangeCharacters (s: string) (target: string) : int =  ",78    "scala_template": "def rearrangeCharacters(s: String,target: String): Int = { \n    \n}",79    "java_template": "class Solution {\n    public int rearrangeCharacters(String s, String target) {\n        \n    }\n}",80    "python_template": "class Solution(object):\n    def rearrangeCharacters(self, s, target):\n        \"\"\"\n        :type s: str\n        :type target: str\n        :rtype: int\n        \"\"\"\n        "81}