Completed Design - 1 - #2693
Open
satish-paraddi wants to merge 4 commits into
Open
Conversation
Owner
Design HashSet (design_1.py)[Constructive feedback for this student] VERDICT: PASS Min Stack (problem-1.py)Excellent work! Your solution correctly implements the MinStack with O(1) time complexity using the two-stack approach. The logic is sound and handles all edge cases properly. Strengths:
Suggestions for improvement:
Here's an enhanced version with these improvements: class MinStack:
def __init__(self):
"""
Initialize your data structure here.
"""
self.st = []
self.min_st = []
self.min = float('inf')
def push(self, val: int) -> None:
"""
Push element val onto stack.
"""
if self.min >= val:
self.min_st.append(self.min)
self.min = val
self.st.append(val)
def pop(self) -> None:
"""
Removes the element on top of the stack.
"""
if self.st.pop() == self.min:
self.min = self.min_st.pop()
def top(self) -> int:
"""
Get the top element.
"""
return self.st[-1]
def getMin(self) -> int:
"""
Retrieve the minimum element in the stack.
"""
return self.minOverall, your solution is correct, efficient, and well-written. Keep up the good work! VERDICT: PASS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.