Identify the Problem Flashcards

1
Q

A Stack is ____
A. FIFO
B. LIFO

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Validate Parentheses
You are given a string s consisting of the following characters: ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’.

The input string s is valid if and only if:

Every open bracket is closed by the same type of close bracket.
Open brackets are closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.
Return true if s is a valid string, and false otherwise.

What data structure should you use to solve.

A

Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A Queue is ____
A. FIFO
B. LIFO

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Generate Parentheses
You are given an integer n. Return all well-formed parentheses strings that you can generate with n pairs of parentheses.

Example 1:

Input: n = 1

Output: [”()”]
Example 2:

Input: n = 3

Output: [”((()))”,”(()())”,”(())()”,”()(())”,”()()()”]
You may return the answer in any order.

A

Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly