Back to problems

Merge K Sorted (Key, Value) Lists with Later Override

Algorithm · Oracle · Medium

Requirements Input consists of k linked lists l_0, l_1, ..., l_{k-1}. Every list holds (key, value) entries ordered by increasing key, and no list repeats a key internally. When the same key occurs in more than one list, retain the value from the list having the greatest index; for example, l_2 takes precedence over both l_0 and l_1. Return a single linked list containing (key, value) entries in ascending key order after applying that precedence rule. Examples Explanation:…

Checking your access…