To the Top
File:  root - text - article - 2019 - 11 - queue-using-two-stacks.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 303 Views, 18078 Search Bots | 93 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Apple:

Implement a queue class using two stacks. A queue is a data structure that supports the FIFO protocol (First in = first out). Your class should support the enqueue and dequeue methods like a standard queue.

Here's a starting point:


class Queue:
def __init__(self):
# Fill this in.

def enqueue(self, val):
# Fill this in.

def dequeue(self):
# Fill this in.

q = Queue()
q.enqueue(1)
q.enqueue(2)
q.enqueue(3)
print q.dequeue()
print q.dequeue()
print q.dequeue()
# 1 2 3
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 303 Views, 18078 Search Bots | 93 Words Subscribe to Feed Burner

Related Articles

  1. Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
  2. Daily Interview Problem: Largest BST in a Binary Tree
  3. Daily Interview Question: Longest Sequence with Two Unique Numbers
  4. Spectrum Master
  5. Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
  6. Daily Interview Question: Word Search
  7. Daily Interview Problem: Group Words that are Anagrams
  8. Daily Interview Problem: Circle of Chained Words
  9. CVE-2015-8874 - cPanel EasyApache Vulnerabilities
  10. [Daily Problem] Move Zeros

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />