Working Java Program For Largest Rectangle in Histogram

Here we will try to find a solution for largest rectangle in histogram problem. We will use “LeetCode 84. Largest Rectangle in Histogram” problem as an example here. It says: Given an array of integers heights representing the histogram’s bar height where the width of each bar is 1, return the area of the largest … Read more

Java Code Implementation For All Unique Permutations

We will try to find all possible permutations of a given string. To understand this problem, we will use “LeetCode problem 47. Permutations II” and solve it. The problem states that: Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. Input: nums = [1,1,2] Output: [[1,1,2], … Read more

Evaluate Reverse Polish Notation In Java

We will evaluate postfix expression here. Postfix expression is also called Reverse Polish Notation. This is a common LeetCode problem “150. Evaluate Reverse Polish Notation”. Let’s take an example & see how postfix expression works. Input: [“6”, “1”, “-“, “3”, “*”] Output: 15 Postfix means operator comes after the two operands. If you see the … Read more

How To Find Recurring Sequence In A Fraction

We are here to solve a LeetCode problem “166. Fraction to Recurring Decimal“. The problem states that: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses. Non-repeating Sequence Example: Input: numerator = 1, denominator = … Read more