Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to create a custom stack class with a GetMin() method to retrieve the minimum element in constant time.

Hard

Problem Statement

Write a program to create a custom stack class with a GetMin() method to retrieve the minimum element in constant time.

Sample Input

Operations: Push(5), Push(3), Push(7), Pop(), GetMin()

Sample Output

Minimum Element: 3

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
using System; class MinStack { static void Main() { // Implement a stack with a GetMin() method } }
Log in or sign up to run or submit your code.Log inSign up
Input
Operations: Push(5), Push(3), Push(7), Pop(), GetMin()
Expected Output
Minimum Element: 3