kimmikimmi / leetcode_problem_solving

MIT License
2 stars 1 forks source link

Min stack is not underatandable #3

Closed kimmikimmi closed 4 years ago

kimmikimmi commented 4 years ago

please tell me how does it work, specially this part below

    def push(self, x: int) -> None:
        self.stack.append(x)

        if not self.minStack: #list is empty
            self.minStack.append(x)
        else:
            current = min(self.minStack[-1], x)
            self.minStack.append(current)

can you tell me how does the logic go?

kimmikimmi commented 4 years ago

Closes