How would you implement a custom stack or queue using basic arrays or linked lists?
Implement process_operations(mode, operations), where mode is either "stack" or "queue". Each operation is an array such as ["push", value], ["pop"], ["enqueue", value], or ["dequeue"]. Return the values produced by removal and peek operations in order. Return None for removal or peek operations on an empty structure.
Use a custom implementation rather than the built-in queue classes. The structure should support constant-time insertion, removal, and peek operations.
def process_operations(mode, operations):