a "deque" is a data structure consisting of a list of items, on which the following operations are possible: push(x,d): insert item x on the front end of deque d. pop(d): remove the front item from deque d and return it. inject(x,d): insert item x on the rear end of deque d. eject(d): remove the rear item from deque d and return it. write routines to support the deque that take o(1) time per operation.
时间: 2023-04-29 12:07:24 浏览: 141
“双端队列(deque)”是一种数据结构,由一系列项组成,支持以下操作:push(x,d):将项x插入队列d的前端,pop(d):从队列d的前端删除项并返回它,inject(x,d):将项x插入队列d的末尾,eject(d):从队列d的末尾删除项并返回它。编写程序支持deque,并保证每个操作所需的时间为O(1)。
阅读全文