Skip to content

Done design-2#2449

Open
pranjay01 wants to merge 1 commit intosuper30admin:masterfrom
pranjay01:master
Open

Done design-2#2449
pranjay01 wants to merge 1 commit intosuper30admin:masterfrom
pranjay01:master

Conversation

@pranjay01
Copy link

No description provided.

@super30admin
Copy link
Owner

Your solution for the queue using stacks is excellent. It correctly implements the required operations with the right time and space complexity. The code is clean and well-commented. Here are a few minor suggestions:

  1. In the empty method, you can simplify the return statement to return not self.enteringStack and not self.outgoingStack. This is more idiomatic in Python and avoids calling len twice.

  2. Although the problem states that all calls to pop and peek are valid, it's still a good practice to handle edge cases (like when both stacks are empty) in the pop and peek methods. However, since the problem guarantees valid calls, it's acceptable as is.

Overall, great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants