{"id":"6b093ddfbd4755deb67ee089","slug":"min-stack","title":"Stos z minimum w O(1)","summary":"Projektujemy stos, który oprócz push, pop i top w stałym czasie zwraca też najmniejszy element. Pytanie o kompromis pamięć–czas.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"algorithms","status":"published","difficulty":"easy","topics":[],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["stack","design","data-structures"],"languages":[{"lang":"typescript","runner":"browser","starter":"class MinStack {\n  /** Pushes x. */\n  push(x: number): void {\n    throw new Error('Not implemented');\n  }\n\n  /** Removes and returns the top element; Error('Stack is empty') when empty. */\n  pop(): number {\n    throw new Error('Not implemented');\n  }\n\n  /** Returns the top element; Error('Stack is empty') when empty. */\n  top(): number {\n    throw new Error('Not implemented');\n  }\n\n  /** Returns the smallest element; Error('Stack is empty') when empty. */\n  getMin(): number {\n    throw new Error('Not implemented');\n  }\n\n  get size(): number {\n    throw new Error('Not implemented');\n  }\n}\n","testCount":6,"tests":"test('top and getMin after pushes', () => {\n  const s = new MinStack();\n  s.push(5);\n  s.push(3);\n  s.push(7);\n  expect(s.top()).toBe(7);\n  expect(s.getMin()).toBe(3);\n  expect(s.size).toBe(3);\n});\n\ntest('pop returns the value and restores the previous minimum', () => {\n  const s = new MinStack();\n  [5, 3, 7, 2].forEach((x) => s.push(x));\n  expect(s.getMin()).toBe(2);\n  expect(s.pop()).toBe(2);\n  expect(s.getMin()).toBe(3);\n  expect(s.pop()).toBe(7);\n  expect(s.getMin()).toBe(3);\n  expect(s.pop()).toBe(3);\n  expect(s.getMin()).toBe(5);\n  expect(s.size).toBe(1);\n});\n\ntest('repeated minimums', () => {\n  const s = new MinStack();\n  [2, 2, 1, 1].forEach((x) => s.push(x));\n  s.pop();\n  expect(s.getMin()).toBe(1);\n  s.pop();\n  expect(s.getMin()).toBe(2);\n  s.pop();\n  expect(s.getMin()).toBe(2);\n});\n\ntest('negative values', () => {\n  const s = new MinStack();\n  [-1, -5, 4, -5].forEach((x) => s.push(x));\n  expect(s.getMin()).toBe(-5);\n  s.pop();\n  expect(s.getMin()).toBe(-5);\n  s.pop();\n  s.pop();\n  expect(s.getMin()).toBe(-1);\n});\n\ntest('empty stack throws', () => {\n  const s = new MinStack();\n  expect(s.size).toBe(0);\n  expect(() => s.pop()).toThrow('Stack is empty');\n  expect(() => s.top()).toThrow('Stack is empty');\n  expect(() => s.getMin()).toThrow('Stack is empty');\n  s.push(1);\n  s.pop();\n  expect(() => s.getMin()).toThrow('Stack is empty');\n});\n\ntest('performance: 100 000 operations of each kind', () => {\n  const s = new MinStack();\n  const n = 100000;\n  let checksum = 0;\n  for (let i = 0; i < n; i++) {\n    s.push(n - i);\n    checksum += s.getMin();\n  }\n  for (let i = 0; i < n; i++) {\n    checksum += s.getMin() + s.pop();\n  }\n  expect(s.size).toBe(0);\n  expect(checksum).toBe(3 * (n * (n + 1)) / 2);\n});\n"},{"lang":"javascript","runner":"browser","starter":"class MinStack {\n  /** Pushes x. */\n  push(x) {\n    throw new Error('Not implemented');\n  }\n\n  /** Removes and returns the top element; Error('Stack is empty') when empty. */\n  pop() {\n    throw new Error('Not implemented');\n  }\n\n  /** Returns the top element; Error('Stack is empty') when empty. */\n  top() {\n    throw new Error('Not implemented');\n  }\n\n  /** Returns the smallest element; Error('Stack is empty') when empty. */\n  getMin() {\n    throw new Error('Not implemented');\n  }\n\n  get size() {\n    throw new Error('Not implemented');\n  }\n}\n","testCount":6,"tests":"test('top and getMin after pushes', () => {\n  const s = new MinStack();\n  s.push(5);\n  s.push(3);\n  s.push(7);\n  expect(s.top()).toBe(7);\n  expect(s.getMin()).toBe(3);\n  expect(s.size).toBe(3);\n});\n\ntest('pop returns the value and restores the previous minimum', () => {\n  const s = new MinStack();\n  [5, 3, 7, 2].forEach((x) => s.push(x));\n  expect(s.getMin()).toBe(2);\n  expect(s.pop()).toBe(2);\n  expect(s.getMin()).toBe(3);\n  expect(s.pop()).toBe(7);\n  expect(s.getMin()).toBe(3);\n  expect(s.pop()).toBe(3);\n  expect(s.getMin()).toBe(5);\n  expect(s.size).toBe(1);\n});\n\ntest('repeated minimums', () => {\n  const s = new MinStack();\n  [2, 2, 1, 1].forEach((x) => s.push(x));\n  s.pop();\n  expect(s.getMin()).toBe(1);\n  s.pop();\n  expect(s.getMin()).toBe(2);\n  s.pop();\n  expect(s.getMin()).toBe(2);\n});\n\ntest('negative values', () => {\n  const s = new MinStack();\n  [-1, -5, 4, -5].forEach((x) => s.push(x));\n  expect(s.getMin()).toBe(-5);\n  s.pop();\n  expect(s.getMin()).toBe(-5);\n  s.pop();\n  s.pop();\n  expect(s.getMin()).toBe(-1);\n});\n\ntest('empty stack throws', () => {\n  const s = new MinStack();\n  expect(s.size).toBe(0);\n  expect(() => s.pop()).toThrow('Stack is empty');\n  expect(() => s.top()).toThrow('Stack is empty');\n  expect(() => s.getMin()).toThrow('Stack is empty');\n  s.push(1);\n  s.pop();\n  expect(() => s.getMin()).toThrow('Stack is empty');\n});\n\ntest('performance: 100 000 operations of each kind', () => {\n  const s = new MinStack();\n  const n = 100000;\n  let checksum = 0;\n  for (let i = 0; i < n; i++) {\n    s.push(n - i);\n    checksum += s.getMin();\n  }\n  for (let i = 0; i < n; i++) {\n    checksum += s.getMin() + s.pop();\n  }\n  expect(s.size).toBe(0);\n  expect(checksum).toBe(3 * (n * (n + 1)) / 2);\n});\n"},{"lang":"python","runner":"browser","starter":"class MinStack:\n    def push(self, x: int) -> None:\n        raise NotImplementedError\n\n    def pop(self) -> int:\n        \"\"\"Removes and returns the top element; IndexError when empty.\"\"\"\n        raise NotImplementedError\n\n    def top(self) -> int:\n        \"\"\"Returns the top element; IndexError when empty.\"\"\"\n        raise NotImplementedError\n\n    def get_min(self) -> int:\n        \"\"\"Returns the smallest element; IndexError when empty.\"\"\"\n        raise NotImplementedError\n\n    def __len__(self) -> int:\n        raise NotImplementedError\n","testCount":6,"tests":"def eq(got, expected, what):\n    assert got == expected, f\"{what}: expected {expected}, got {got}\"\n\n\ndef test_top_and_get_min_after_pushes():\n    s = MinStack()\n    for x in (5, 3, 7):\n        s.push(x)\n    eq(s.top(), 7, \"top()\")\n    eq(s.get_min(), 3, \"get_min()\")\n    eq(len(s), 3, \"len()\")\n\n\ndef test_pop_restores_previous_minimum():\n    s = MinStack()\n    for x in (5, 3, 7, 2):\n        s.push(x)\n    eq(s.get_min(), 2, \"get_min()\")\n    eq(s.pop(), 2, \"pop()\")\n    eq(s.get_min(), 3, \"get_min() after popping 2\")\n    eq(s.pop(), 7, \"pop()\")\n    eq(s.get_min(), 3, \"get_min() after popping 7\")\n    eq(s.pop(), 3, \"pop()\")\n    eq(s.get_min(), 5, \"get_min() after popping 3\")\n    eq(len(s), 1, \"len()\")\n\n\ndef test_repeated_minimums():\n    s = MinStack()\n    for x in (2, 2, 1, 1):\n        s.push(x)\n    s.pop()\n    eq(s.get_min(), 1, \"get_min() after one pop\")\n    s.pop()\n    eq(s.get_min(), 2, \"get_min() after two pops\")\n    s.pop()\n    eq(s.get_min(), 2, \"get_min() after three pops\")\n\n\ndef test_negative_values():\n    s = MinStack()\n    for x in (-1, -5, 4, -5):\n        s.push(x)\n    eq(s.get_min(), -5, \"get_min()\")\n    s.pop()\n    eq(s.get_min(), -5, \"get_min() after one pop\")\n    s.pop()\n    s.pop()\n    eq(s.get_min(), -1, \"get_min() after three pops\")\n\n\ndef test_empty_stack_raises():\n    s = MinStack()\n    eq(len(s), 0, \"len() of a new stack\")\n    with raises(IndexError):\n        s.pop()\n    with raises(IndexError):\n        s.top()\n    with raises(IndexError):\n        s.get_min()\n    s.push(1)\n    s.pop()\n    with raises(IndexError):\n        s.get_min()\n\n\ndef test_performance_100k_operations():\n    s = MinStack()\n    n = 100_000\n    checksum = 0\n    for i in range(n):\n        s.push(n - i)\n        checksum += s.get_min()\n    for _ in range(n):\n        checksum += s.get_min() + s.pop()\n    eq(len(s), 0, \"len() at the end\")\n    eq(checksum, 3 * n * (n + 1) // 2, \"checksum\")\n"},{"lang":"csharp","runner":"judge0","starter":"using System;\n\npublic class MinStack\n{\n    public void Push(int x)\n    {\n        throw new NotImplementedException();\n    }\n\n    /// <summary>Removes and returns the top element; InvalidOperationException when empty.</summary>\n    public int Pop()\n    {\n        throw new NotImplementedException();\n    }\n\n    /// <summary>Returns the top element; InvalidOperationException when empty.</summary>\n    public int Top()\n    {\n        throw new NotImplementedException();\n    }\n\n    /// <summary>Returns the smallest element; InvalidOperationException when empty.</summary>\n    public int GetMin()\n    {\n        throw new NotImplementedException();\n    }\n\n    public int Count\n    {\n        get { throw new NotImplementedException(); }\n    }\n}\n","testCount":6},{"lang":"java","runner":"judge0","starter":"class MinStack {\n    void push(int x) {\n        throw new UnsupportedOperationException(\"Not implemented\");\n    }\n\n    /** Removes and returns the top element; IllegalStateException when empty. */\n    int pop() {\n        throw new UnsupportedOperationException(\"Not implemented\");\n    }\n\n    /** Returns the top element; IllegalStateException when empty. */\n    int top() {\n        throw new UnsupportedOperationException(\"Not implemented\");\n    }\n\n    /** Returns the smallest element; IllegalStateException when empty. */\n    int getMin() {\n        throw new UnsupportedOperationException(\"Not implemented\");\n    }\n\n    int size() {\n        throw new UnsupportedOperationException(\"Not implemented\");\n    }\n}\n","testCount":6},{"lang":"go","runner":"judge0","starter":"package main\n\ntype MinStack struct {\n\t// TODO\n}\n\nfunc NewMinStack() *MinStack {\n\treturn &MinStack{}\n}\n\n// Push pushes x.\nfunc (s *MinStack) Push(x int) {\n\tpanic(\"not implemented\")\n}\n\n// Pop removes and returns the top element; ok is false when the stack is empty.\nfunc (s *MinStack) Pop() (value int, ok bool) {\n\tpanic(\"not implemented\")\n}\n\n// Top returns the top element; ok is false when the stack is empty.\nfunc (s *MinStack) Top() (value int, ok bool) {\n\tpanic(\"not implemented\")\n}\n\n// Min returns the smallest element; ok is false when the stack is empty.\nfunc (s *MinStack) Min() (value int, ok bool) {\n\tpanic(\"not implemented\")\n}\n\nfunc (s *MinStack) Len() int {\n\tpanic(\"not implemented\")\n}\n","testCount":6}],"questionCount":null,"xp":10,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:55.005Z","requestedLang":"pl","statement":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Edytor z historią zmian trzyma wartości na stosie i co chwilę pyta o "},{"type":"text","text":"najmniejszą","marks":[{"type":"bold"}]},{"type":"text","text":" z nich. Przeszukiwanie całego stosu przy każdym pytaniu jest za wolne – potrzebna jest struktura "},{"type":"text","text":"MinStack","marks":[{"type":"code"}]},{"type":"text","text":", w której "},{"type":"text","text":"każda","marks":[{"type":"bold"}]},{"type":"text","text":" operacja działa w czasie O(1)."}]},{"type":"heading","attrs":{"level":2,"id":"zadanie"},"content":[{"type":"text","text":"Zadanie"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Operacja"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Działanie"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"push(x)","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"odkłada liczbę całkowitą "},{"type":"text","text":"x","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"pop()","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zdejmuje i "},{"type":"text","text":"zwraca","marks":[{"type":"bold"}]},{"type":"text","text":" element z wierzchołka"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"top()","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zwraca element z wierzchołka bez zdejmowania"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"getMin()","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zwraca najmniejszy element na stosie"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"size","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"liczba elementów"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"pop","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"top","marks":[{"type":"code"}]},{"type":"text","text":" i "},{"type":"text","text":"getMin","marks":[{"type":"code"}]},{"type":"text","text":" na pustym stosie zgłaszają błąd:"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Język"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Nazwy"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Pusty stos"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"JS/TS"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"push","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"pop","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"top","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"getMin","marks":[{"type":"code"}]},{"type":"text","text":", getter "},{"type":"text","text":"size","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Error('Stack is empty')","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Python"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"push","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"pop","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"top","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"get_min","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"len(stack)","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"IndexError","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"C#"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Push","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Pop","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Top","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"GetMin","marks":[{"type":"code"}]},{"type":"text","text":", właściwość "},{"type":"text","text":"Count","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"InvalidOperationException","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Java"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"push","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"pop","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"top","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"getMin","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"size()","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"IllegalStateException","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Go"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"NewMinStack()","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Push","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Pop","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Top","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Min","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Len","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"drugi wynik "},{"type":"text","text":"ok == false","marks":[{"type":"code"}]}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"przyklad"},"content":[{"type":"text","text":"Przykład"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Operacje"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Wynik"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"push(5)","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"push(3)","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"push(7)","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"top() = 7","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"getMin() = 3","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"push(2)","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"getMin() = 2","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"pop()","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zwraca "},{"type":"text","text":"2","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"getMin() = 3","marks":[{"type":"code"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"pop()","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"pop()","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zwracają "},{"type":"text","text":"7","marks":[{"type":"code"}]},{"type":"text","text":" i "},{"type":"text","text":"3","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"getMin() = 5","marks":[{"type":"code"}]}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"ograniczenia"},"content":[{"type":"text","text":"Ograniczenia"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Do 100 000 operacji w jednym teście, wartości z zakresu 32-bitowego "},{"type":"text","text":"int","marks":[{"type":"code"}]},{"type":"text","text":"."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Minimum może się powtarzać (np. "},{"type":"text","text":"push(1)","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"push(1)","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"pop()","marks":[{"type":"code"}]},{"type":"text","text":" – minimum nadal wynosi 1)."}]}]}]},{"type":"heading","attrs":{"level":2,"id":"oczekiwana-zlozonosc"},"content":[{"type":"text","text":"Oczekiwana złożoność"}]},{"type":"paragraph","content":[{"type":"text","text":"Każda operacja "},{"type":"text","text":"O(1)","marks":[{"type":"bold"}]},{"type":"text","text":", pamięć "},{"type":"text","text":"O(n)","marks":[{"type":"bold"}]},{"type":"text","text":"."}]}]},"hints":[],"hintsCount":3,"quiz":null,"solutionNotes":null,"unlocked":false,"external":[{"provider":"leetcode","url":"https://leetcode.com/problems/min-stack/","title":"LeetCode 155 – Min Stack","difficulty":null}],"articles":[],"topicsInfo":[],"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"capabilities":{"judge0":false,"aiReview":false},"createdAt":"2026-11-27T08:22:55.007Z","updatedAt":"2026-11-27T08:22:55.007Z"}