Problem Β· String
URL Hashing π©
Learn this problemProblem statement
Implement an algorithm to hash a URL as described.
Suppose the given URL url of length n is to be hashed with a string hash_string of length m. Given an integer k, run the url through the following algorithm:
k starting from the left. The last block can be smaller than k. For example, if url = "https://xyz.com" and k = 4, the blocks are ["http", "s://", "xyz.", "com"].m)th character of the string hash_string.
Given the string url, hash_string, and an integer k, find the hashed string.
Function
hashUrl(url: String, hashString: String, k: int) β StringExamples
Example 1
url = "https://xyz.com"hashString = "pqrst"k = 4return = "psps"
Each hash value is divided by the len of hash_strong or 5 in this case. The remainders oint to the characters in hash_string, and the answer is "psps".
Constraints
Unknwo for now πΌMore Tiktok problems
- Can Reach the Exit with TeleportsOA Β· Seen Jul 2026
- Check Monotonic TriplesOA Β· Seen Jul 2026
- Shift Every K-th ConsonantOA Β· Seen Jul 2026
- Count Access Code PairsOA Β· Seen Jul 2026
- Count Key ChangesOA Β· Seen Jul 2026
- Sort Matrix BordersOA Β· Seen Jul 2026
- Travel Distance on ScootersOA Β· Seen Jul 2026
- Validate 3x3 Digit WindowsOA Β· Seen Jul 2026