FPEvalDataset/LeetCodeProblem
0302
1{2 "id": 3540,3 "name": "hash_divided_string",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/hash-divided-string/",6 "date": "2024-08-17 00:00:00",7 "task_description": "You are given a string `s` of length `n` and an integer `k`, where `n` is a **multiple** of `k`. Your task is to hash the string `s` into a new string called `result`, which has a length of `n / k`. First, divide `s` into `n / k` **substrings**, each with a length of `k`. Then, initialize `result` as an **empty** string. For each **substring** in order from the beginning: The **hash value** of a character is the index of that character in the **English alphabet** (e.g., `'a' → 0`, `'b' → 1`, ..., `'z' → 25`). Calculate the _sum_ of all the **hash values** of the characters in the substring. Find the remainder of this sum when divided by 26, which is called `hashedChar`. Identify the character in the English lowercase alphabet that corresponds to `hashedChar`. Append that character to the end of `result`. Return `result`. **Example 1:** **Input:** s = \"abcd\", k = 2 **Output:** \"bf\" **Explanation:** First substring: `\"ab\"`, `0 + 1 = 1`, `1 % 26 = 1`, `result[0] = 'b'`. Second substring: `\"cd\"`, `2 + 3 = 5`, `5 % 26 = 5`, `result[1] = 'f'`. **Example 2:** **Input:** s = \"mxz\", k = 3 **Output:** \"i\" **Explanation:** The only substring: `\"mxz\"`, `12 + 23 + 25 = 60`, `60 % 26 = 8`, `result[0] = 'i'`. **Constraints:** `1 <= k <= 100` `k <= s.length <= 1000` `s.length` is divisible by `k`. `s` consists only of lowercase English letters.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "s = \"abcd\", k = 2",12 "output": "\"bf\" "13 },14 {15 "label": "Example 2",16 "input": "s = \"mxz\", k = 3",17 "output": "\"i\" "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 "\"mknnewhsvixaeusxsfojlvplbqyjyefrjyyhtajuilrfkjghjnsvnqaydn\"",24 5825 ],26 "output": "h"27 },28 {29 "input": [30 "\"hkbsjdlmmpstbixdukm\"",31 1932 ],33 "output": "e"34 },35 {36 "input": [37 "\"hrenpeulegbdevkqxkgunlvgjcgcnkyfveviopkctwxwhbbkolfhagijdtrdizpirypifljngxpnptiieyomhqjjktmgoenqopchwgogggndissmbydubfvnydiiishhouqhtpyrzrfprmincrzitkspkqzrmqyendodxzqfoshzusltfmlryehtrbkjmfedsamvuitkilacsmmhbkvngiaaggirnphjxtfegigchuagijfyinrqcnqolrrtstnikodwzxkqgqvcodvgeyiyprivurjsfggblcdhutatqxcaszyplcjyxhvxjdjnbnmolpkqjfcjntszgitnmhnrxjpkpqzibqreaalrcdjxdzhgkotxgcngwtqkpsuxpqesdljpxflnczyajozieygfecszaxnkwwawzdacpermpwcivdviveknyjvlzyyjkedipifsiksmhofosobpjbxmjtxfheetuzozcwybccmdkyphebjngzmesjhxvgfcllrjsicgogubevwoyqclpkinjgmowkmqbbbjgnlruztuvssvpzexnticbbqnfprshbtbcomjsiwnnjuvvv\"",38 5939 ],40 "output": "mfghqouxbh"41 },42 {43 "input": [44 "\"qsxlpirfwsthwxzadtjsrzwzkcdbamjlkvimwhimffqwjjgmgaeygpxjheaahqqmtgooaybcybycgfvlimxuksbqbtqkddgussimvqoagtuvrjysyxjifasioqcmtsynguoiblpvqqxudxjcdokpbdkvxsqjextaiyubizlcjrdrwfsvivnmxcknskwkznvekfaileikjclsqsfjhmfxcphvdedxjznytvlpuhwigpixxycbbamgelxwwfhkpjsgqewpixzmpftsbaewaujcowqaqaulumntwxjysxcgwpezewkvddbsrymkwwyhkuguawfljwuaqsldbwuxxfbmtbrgrsvqlpvtsyeascudehuenihqah\"",45 3746 ],47 "output": "obknkshumu"48 },49 {50 "input": [51 "\"imdlgramytqqhnxvrssthdpmsymozgryvqfytyufmrhzctoqcntuyrsjswjeqy\"",52 3153 ],54 "output": "rr"55 },56 {57 "input": [58 "\"mrcfbffhqqxjcsicacqwxydlitlcacwbzvkbnpofpjztlptsigapmfowackpdvbscvbzvwcjeoewrtaxigvysjwxokurihlt\"",59 4860 ],61 "output": "dx"62 },63 {64 "input": [65 "\"mtztdwkprxmyslkvbzbctmdvkbgeqqvjtlelfxweovjijdckkxvftardiknyrvavdpvxafjbptmxzqlymyjjvrphubfbczwfhqdpvrvzvhuchzvyykdzzpxzxoffxhgzrvljihabhdpallqikkgkafwmlqtwsikhmrmamwswpxiinlncjuwndgxguhzuckqaukbodcinwublsvpftqwmpgaptfpajzsejcrpjechadcfxjdxmleklprvbgwcfjoriznbwryevhbyfdtaswzeqyogsgustciuedccxazekzgmoxaxbextrcktiphwjbtfffhslzxfishinywflldkozkkamtjpcwkuhcdshfmoadlfoalpvyfktmytetiwsscckeqpppuewghuhgangabrkqkwgibulxtyegiinfpbysbatidnxiqmlduqybpsftzzduyjemfyohwruxxettnfsfdliadoehlqwwhmvkcidpxkjxhhggtnctaczmilwsbaanyzhoktyhbqkpv\"",66 6667 ],68 "output": "bffewqcx"69 },70 {71 "input": [72 "\"tveaugfeecjmlzdskgaz\"",73 574 ],75 "output": "mvih"76 },77 {78 "input": [79 "fwwlcqeiznjbsellbqoyydgqvghkxfpqwhbrceaapetqfjff",80 2481 ],82 "output": "aa"83 },84 {85 "input": [86 "lzrjjwaxglcicsujxldilsqdcazfiknweaavbyfpikbkvduavjxdpsnuuitabguyqhevqjjbqjhkbjhhndqwtflawguetmibvirgxomrkeoqufgbwwyzofxpphyumynhzvpqtnfuzsgbczcqoxasdrljnhytwgvjdzxdxqongohlqyztxuqaobhwdokrfkrjaktoeuovnpnyftjttydihvueifjhdmznimbqbvhsqjgqdxkpoogqanfakqlfxjuvsqxavytbbtvfhotridmdcxgbfniaqsdmbxsobicwmkamwljpaqpfjsglrwozobzwbavbpdliaqkbblqonvkglpkqhdbrgf",87 7088 ],89 "output": "axrnr"90 }91 ],92 "haskell_template": "stringHash :: String -> Int -> String\nstringHash s k ",93 "ocaml_template": "let stringHash (s: string) (k: int) : string = ",94 "scala_template": "def stringHash(s: String,k: Int): String = { \n \n}",95 "java_template": "class Solution {\n public String stringHash(String s, int k) {\n \n }\n}",96 "python_template": "class Solution(object):\n def stringHash(self, s, k):\n \"\"\"\n :type s: str\n :type k: int\n :rtype: str\n \"\"\"\n "97}