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.
Examples
01 Β· Example 1
url = "https://xyz.com" hashString = "pqrst" k = 4 return = "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
- LRU Cache with TTL ExpirationONSITE INTERVIEW Β· Seen May 2026
- Maximum Candies with At Most Two Types in a LineONSITE INTERVIEW Β· Seen May 2026
- Top-K KOLs by Total LikesONSITE INTERVIEW Β· Seen May 2026
- Compute Walking DistanceSeen Mar 2026
- Count Sawtooth SubarraysSeen Mar 2026
- Format TextSeen Mar 2026
- Memory AllocatorSeen Mar 2026
- TikTok Shopping SpreeSeen Mar 2025
public String hashUrl(String url, String hashString, int k) {
// write your code here
}
url"https://xyz.com"
hashString"pqrst"
k4
expected"psps"
sign in to submit