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

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