We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The current solution is:
class MinStack: def __init__(self): self.stack = [] self.minStack = [] def push(self, val: int) -> None: self.stack.append(val) val = min(val, self.minStack[-1] if self.minStack else val) self.minStack.append(val) def pop(self) -> None: self.stack.pop() self.minStack.pop() def top(self) -> int: return self.stack[-1] def getMin(self) -> int: return self.minStack[-1]
within push, I think the current line is a little bit misleading as it's currently written as
push
val = min(val, self.minStack[-1] if self.minStack else val)
and writing it as
val = min(val, self.minStack[-1]) if self.minStack else val
is more readable to me.
Correct me if I'm wrong, thanks.
The text was updated successfully, but these errors were encountered:
The other version may indeed be slightly more readable to some due to its straightforward structure.
Sorry, something went wrong.
True, your version is more readable.
No branches or pull requests
The current solution is:
within
push
, I think the current line is a little bit misleading as it's currently written asand writing it as
is more readable to me.
Correct me if I'm wrong, thanks.
The text was updated successfully, but these errors were encountered: