-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Create min_stack.py #2458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create min_stack.py #2458
Conversation
Why? There is no description when or why this algorithm would be useful. No doctests to prove that it works as intended. Python method names should be in snake_case as discussed in CONTRIBUTING.md. Seems like a lot of code for an algorithm that could be implemented in 5 lines of Python. |
add some doctests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated min_stack.py with doc test and snake_case function definition.
@@ -1,11 +1,19 @@ | |||
class MinStack: | |||
""" Designing a Stack that can return Minimum element in Constant time""" | |||
|
|||
def __init__(self): | |||
""" Creating stack minStack and size Variable""" | |||
self.stack = [] | |||
self.minStack = [] | |||
self.size = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see #2477 (comment) and implement .__iter__()
and .__len__()
methods for this class. .__iter__()
should return values in min-to-max order.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions! |
Describe your change:
Creating a Min Stack that can give minimum element in stack in constant time.
Checklist:
Fixes: #{$ISSUE_NO}
.