Coding Interviews

Leetcode 895: 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: Examples First Example : Constraints: Solution Approach Solution Logic In this problem of Maximum Frequency Stack, the main task is to find the frequency of the value in the stack. …

Leetcode 895: Maximum Frequency Stack Read More »

Leetcode 31: Next Permutation

CATEGORY: MEDIUM Problem A permutation of an array of integers is an arrangement of its members into a sequence or linear order. The next permutation of an array of integers is the next lexicographically greater permutation of its integer. More formally, if all the permutations of the array are sorted in one container according to their lexicographical order, then …

Leetcode 31: Next Permutation 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 »