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
Arithmetic Slices | February Leetcoding Challenge 2021 | Day 18

A zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 <= P < Q < N. A slice (P, Q) of the array A is called arithmetic if the sequence: A[P], A[P + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this means that P + 1 < Q. The function should return the number of arithmetic slices in the array A.

0 Comments