How would you implement a deque in O(1) time complexity that supports push and pop at both ends and also random access?