Question DSA-STK-0007
EasyWhat is the time complexity of push and pop on a stack implemented with an array (with spare capacity)?
- A.
O(log n)
- B.
O(1)
- C.
Show answer and explanation
Answer: B
Both work only at the top.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Stacks question
What is the time complexity of push and pop on a stack implemented with an array (with spare capacity)?
O(log n)
O(1)
Answer: B
Both work only at the top.
O(n²)
O(n)