Maximum Frequency Stack | February Leetcoding Challenge 2021 | Day 28

implement FreqStack, a class which simulates the operation of a stack-like data structure.FreqStack has two functions:push(int x), which pushes an integer x onto the stack.pop(), which removes and returns the most frequent element in the stack.If there is a tie for most frequent element, the element closest to the top of the stack is removed and returned.

0 Comments
Divide Two Integers | February Leetcoding challenge 2021 | Day 27

Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. Return the quotient after dividing dividend by divisor. The integer division should truncate toward zero, which means losing its fractional part. For example, truncate(8.345) = 8 and truncate(-2.7335) = -2.

0 Comments
Broken Calculator | February Leetcoding Challenge 2021 | Day 21

On a broken calculator that has a number showing on its display, we can perform two operations: Double: Multiply the number on the display by 2, or; Decrement: Subtract 1 from the number on the display. Initially, the calculator is displaying the number X. Return the minimum number of operations needed to display the number Y.

1 Comment