## Working Java Program For Largest Rectangle in Histogram

Problem: An array of integers A is given of size N. A represents a histogram i.e A[i] denotes height of the ith histogram’s bar. Width of each bar is 1. This is a question you will find in LeetCode or InterviewBit and asked in interviews of Google, Amazon or Facebook. Above you can see  a histogram with … Read more

## Java Code Implementation For All Unique Permutations

This is a common question asked in interviews of Microsoft, Google & Facebook. You might have stumbled upon this question in LeetCode or InterviewBit. Given a collection of numbers that might contain duplicates, return all possible unique permutations. Input: nums = [1,1,2] Output: [[1,1,2],  [1,2,1],  [2,1,1]] Here is the working solution for this problem in … Read more

## Evaluate Reverse Polish Notation In Java

Here is a fully working Java solution for evaluation of Reverse Polish Notation (Postfix Expression). This is a common interview question that is asked in Google, Yahoo and Facebook. Solution Java class doesn’t have a main() method. You can write a main() method and call evalRPN() method from there. Input argument to evalRPN() method should … Read more

## Java Program To Sort A Linked List

Here is the fully working Java code solution for sorting a Linked List. You can find the same problem as an exercise in LeetCode. I have used Merge Sort here. The expectation here is that the code should run in O(n log n) time complexity and space complexity should be O(1). The below java program … Read more

## QuickSort Implementation In Java

This is a working solution of Quick Sort algorithm in Java. I haven’t written the main method. You can add it & call quickSort(arr, 0, arr.length – 1) with your custom input array. Hope this Java program is self-explanatory. 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940414243 import java.util.*;import java.lang.*;import java.io.*;class Solution{ //Function to … Read more

## Working Merge Sort Implementation In Java

Here is the fully working solution of Merge Sort written in Java. 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 import java.util.*;import java.lang.*;import java.io.*;class Solution{ void merge(int arr[], int l, int m, int r) { int[] leftArr = new int[m – l + 1]; int[] rightArr = new int[r – m]; for(int i=l; i<= … Read more

## How To Find Recurring Sequence In A Fraction

Suppose we have a decimal number. We need to check if the fraction part contains any non-ending repeating sequence or it ends normally. Let’s take an example. Numerator is 5 and denominator is 33. 5 / 33 = 0 5 % 33 = 5 So we need to get the fraction part. 5 * 10 … Read more