CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes572downloads
1{2    "id": 3245,3    "name": "find_beautiful_indices_in_the_given_array_i",4    "difficulty": "Medium",5    "link": "https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/",6    "date": "2024-01-07 00:00:00",7    "task_description": "You are given a **0-indexed** string `s`, a string `a`, a string `b`, and an integer `k`. An index `i` is **beautiful** if: `0 <= i <= s.length - a.length` `s[i..(i + a.length - 1)] == a` There exists an index `j` such that: `0 <= j <= s.length - b.length` `s[j..(j + b.length - 1)] == b` `|j - i| <= k` Return _the array that contains beautiful indices in **sorted order from smallest to largest**_. **Example 1:** ``` **Input:** s = \"isawsquirrelnearmysquirrelhouseohmy\", a = \"my\", b = \"squirrel\", k = 15 **Output:** [16,33] **Explanation:** There are 2 beautiful indices: [16,33]. - The index 16 is beautiful as s[16..17] == \"my\" and there exists an index 4 with s[4..11] == \"squirrel\" and |16 - 4| <= 15. - The index 33 is beautiful as s[33..34] == \"my\" and there exists an index 18 with s[18..25] == \"squirrel\" and |33 - 18| <= 15. Thus we return [16,33] as the result. ``` **Example 2:** ``` **Input:** s = \"abcd\", a = \"a\", b = \"a\", k = 4 **Output:** [0] **Explanation:** There is 1 beautiful index: [0]. - The index 0 is beautiful as s[0..0] == \"a\" and there exists an index 0 with s[0..0] == \"a\" and |0 - 0| <= 4. Thus we return [0] as the result. ``` **Constraints:** `1 <= k <= s.length <= 105` `1 <= a.length, b.length <= 10` `s`, `a`, and `b` contain only lowercase English letters.",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "s = \"isawsquirrelnearmysquirrelhouseohmy\", a = \"my\", b = \"squirrel\", k = 15",12            "output": "[16,33] "13        },14        {15            "label": "Example 2",16            "input": "s = \"abcd\", a = \"a\", b = \"a\", k = 4",17            "output": "[0] "18        }19    ],20    "private_test_cases": [21        {22            "input": [23                "\"mmxcgwgtmxqzsfeyabyzopigemacihvroyvbzrypsaqy\"",24                "\"yvb\"",25                "\"tmxqz\"",26                4027            ],28            "output": [29                3330            ]31        },32        {33            "input": [34                "\"odvruwfxsrmsznh\"",35                "\"uwfxsr\"",36                "\"rmsznh\"",37                1038            ],39            "output": [40                441            ]42        },43        {44            "input": [45                "\"zqxvmsxhqgkvxdkiwxxjsugnpcrddbnsfqlhaorymiczfermp\"",46                "\"v\"",47                "\"vxdk\"",48                3249            ],50            "output": [51                3,52                1153            ]54        },55        {56            "input": [57                "\"usfxluherkpdphorewp\"",58                "\"usfxl\"",59                "\"rkpdph\"",60                1161            ],62            "output": [63                064            ]65        },66        {67            "input": [68                "\"fciwmgkhvuxaroovgwekqjydkymjjypchcfarspknsuvrzcxszaufluzxrtrpyhrkvquhvps\"",69                "\"suvr\"",70                "\"s\"",71                3472            ],73            "output": [74                4175            ]76        },77        {78            "input": [79                "\"zwkerzvlofeffmkzovzjzaxwzxosonvqdjtuazxdfaksbasewkglraejkfjiwbgjvqbcobkipbicqnoqveuhjbbmbmymapvbziymw\"",80                "\"ymapvbziym\"",81                "\"ovzjzaxw\"",82                3683            ],84            "output": []85        },86        {87            "input": [88                "\"mulxtbvpmfzftyxasfuymrcbekchgnjohzdsbvopuudlbsfsgzykbc\"",89                "\"bekch\"",90                "\"asfuymrc\"",91                1492            ],93            "output": [94                2395            ]96        },97        {98            "input": [99                "\"yyevautxxqpbprvjhwuoxpzpdhclagnnqnxjenantikztbmwjyhvdrffltkjuzfsvzocirwnqv\"",100                "\"juzfsvzoci\"",101                "\"autxx\"",102                25103            ],104            "output": []105        },106        {107            "input": [108                "uyafzvzjknaglcxiutlbwgebbbcknhhthuevdtfncoflnxxyutlzmcnliu",109                "lz",110                "tlzm",111                42112            ],113            "output": [114                50115            ]116        },117        {118            "input": [119                "gedfarhinbecdkwucwzjdqvpsvmfxigethfuampsguklhxyxfvyplmpphzpfge",120                "mpph",121                "fxigethfua",122                56123            ],124            "output": [125                53126            ]127        }128    ],129    "haskell_template": "beautifulIndices :: String -> String -> String -> Int -> [Int]\nbeautifulIndices s a b k ",130    "ocaml_template": "let beautifulIndices (s: string) (a: string) (b: string) (k: int) : int list =  ",131    "scala_template": "def beautifulIndices(s: String,a: String,b: String,k: Int): List[Int] = { \n    \n}",132    "java_template": "class Solution {\n    public List<Integer> beautifulIndices(String s, String a, String b, int k) {\n        \n    }\n}",133    "python_template": "class Solution(object):\n    def beautifulIndices(self, s, a, b, k):\n        \"\"\"\n        :type s: str\n        :type a: str\n        :type b: str\n        :type k: int\n        :rtype: List[int]\n        \"\"\"\n        "134}