Your question is Group Array Objects by Key. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
The J.P. Morgan Access dashboard receives payment records as an array of objects. Implement a function that groups these records by a specified object key, returning every record under the value found at that key.
Use a hash map to achieve linear time complexity. The groups must preserve the original order of records, and the order in which distinct groups first appear must also be preserved.
Implement group_by_key(items, key).
items is a list of dictionaries.key is a string, and every dictionary contains that key.items or any dictionary inside it.def group_by_key(items, key):