Coding Interviews

Maximum Frequency Stack

Leetcode 895: Maximum Frequency Stack

CATEGORY: HARD Problem Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: FreqStack() constructs an empty frequency stack. void push(int val) pushes an integer val onto the top of the stack. int pop() removes and returns the most frequent element in the stack. If there is a …

Leetcode 895: Maximum Frequency Stack Read More »

Leetcode 6: Zigzag Conversion

Leetcode 6: Zigzag Conversion

CATEGORY: MEDIUM Problem The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

And then read line by line: “PAYPALISHIRING” Write the code that will take a string and make this conversion given a number …

Leetcode 6: Zigzag Conversion Read More »