Skip to content

Bug Report for minimum-stack #4838

@viktor-richard-ban

Description

@viktor-richard-ban

Bug Report for https://neetcode.io/problems/minimum-stack

When I run my code using the sample input, the output matches expectations. However, when I submit the exact same code, the results differ.

Langauge: Python
Input: ["MinStack", "push", -1, "push", 3, "push", -4, "getMin", "pop", "getMin", "top"]

class MinStack:
    stack = []
    minStack = []

    def push(self, val: int) -> None:
        self.stack.append(val)
        if len(self.minStack) > 0:
            self.minStack.append(min(self.minStack[-1], val))
        else:
            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]

Results:
Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions