## Java Program to Solve Sliding Window Maximum Problem

Here we will understand a common problem solving question from LeetCode. It is “239. Sliding Window Maximum”. You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in … Read more

## 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

## Java Program To Sort A Linked List

We will sort a linked list in optimal way here. We will use “LeetCode 148. Sort List” problem as an example & solve it using Java language. The problem statement is: Given the head of a linked list, return the list after sorting it in ascending order.Follow up: Can you sort the linked list in … Read more

## Quick Sort Implementation In Java

Quick Sort is a notable sorting algorithm. I will try to explain Quick Sort in simple terms. Let’s take an example: Input: 12 25 14 30 15 Output: 12 14 15 25 30 Suppose we have an unsorted array [12, 25, 14, 30, 15] as mentioned above. We will sort the unsorted array using Quick … Read more

## Working Merge Sort Implementation In Java

Should I write an article explaining Merge Sort? There are tons of articles or videos online which explain Merge Sort. What new am I going to add? This is what I thought initially. But after a bit of hesitation, I have decided to write a post on Merge Sort. I would try to explain it … 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