URL Hashing

Company: Boomi_13oct

Difficulty: medium

Problem Statement

URL Hashing Problem Description A link-shortening service turns a long URL into a short code with a simple block hash. You are given the URL url , an alphabet string hash_string and a block size k . Cut url into consecutive blocks of k characters, starting from the left. The last block may be shorter than k if the length of url is not a multiple of k . Give every character a value: the letters a , b , ..., z have the values 0 , 1 , ..., 25 ; the colon : has the value 26 ; the slash / has the value 27 ; the dot . has the value 28 . The hash value of a block is the sum of the values of its characters. Each block is replaced by the single character hash_string[h % len(hash_string)] , where h is the block's hash value and indexing is 0-based. Write a function getHashedURL(url, hash_string, k) that returns the hashed URL: the replacement characters of all blocks, in block order. (inferred -- the source frames are fully blurred and the stored text listed / = 26, . = 27, - = 28. That mapping