---
# System prepended metadata

title: Sprint 3 Module Project 2

---

# Sprint 3 Module Project 2
## queueOnStacks
```
def queueOnStacks(requests):
    left = Stack()
    right = Stack()

    def insert(x):
        left.push(x)

    def remove():
        while not left.isEmpty():
            right.push(left.pop())
        res = right.pop()
        while not right.isEmpty():
            left.push(right.pop())
        return res

    ans = []
    for request in requests:
        req = request.split(" ")
        if req[0] == 'push':
            insert(int(req[1]))
        else:
            ans.append(remove())
    return ans

```
## validBracketSequence
```
from collections import deque

mapping = {')': '(', '}': '{', ']': '['}

def validBracketSequence(sequence):
    stack = deque()
    for char in sequence:
        if char == '(' or char == '{' or char == '[':
            stack.append(char)
        else:
            if len(stack) == 0 or mapping[char] != stack[-1]:
                return False
            else:
                stack.pop()
    return len(stack) == 0

```