Company: Boomi_13oct
Difficulty: medium
URL Hashing Problem Description Implement an algorithm to hash a URL using a specific method. Given a URL, a hash string, and an integer k: Divide the URL into blocks of size k from left to right (the last block may be smaller) Calculate the hash value for each block by summing the values of its characters (a=0, b=1, ..., z=25, /=26, .=27, -=28) Replace each block with the character from the hash string at index (hash value modulo the length of hash_string) Examples Example 1: Input: url = "https://xyz.com", hash_string = "pqrst", k = 4 Output: psps Explanation: Block Hash Value Hash Character http 7 + 19 + 19 + 15 = 60 hash_string[60 % 5] = 0 = p s:// 18 + 26 + 27 + 27 = 98 hash_string[98 % 5] = 3 = s xyz. 23 + 24 + 25 + 28 = 100 hash_string[100 % 5] = 0 = p com 2 + 14 + 12 = 28 hash_string[28 % 5] = 3 = s The hashed URL is "psps". Example 2: Input: url = "https://caayxdcdzwxwc.com", hash_string = "awpixaia", k = 7 Output: iamp Explanation: Block Hash Value Hash Character https:/ 7 +