Societe Generale OA 2024 | Maximum Frequency Stack | Design Data Structure

Question · Posted Jun 2026

Problem Statement Design a stack-like data structure called Frequency Stack that supports the following operations: push(int val) Push an integer val onto the stack. pop() Remove and return the most frequent element currently present in the stack. If multiple elements have the same highest frequency, return the element that was pushed most recently among them. Implement the FreqStack class: FreqStack() Initializes the frequency stack. void push(int val) Pushes an integer onto the stack. int pop() Removes and returns the most ...

The full answer & interview discussion are available to premium members.

Log in Create a free account