From 922ccb315a8a6c2ead74e632da55aa5e226c1b2f Mon Sep 17 00:00:00 2001 From: Rashid <19051001@kiit.ac.in> Date: Sun, 10 Oct 2021 18:28:03 +0530 Subject: [PATCH 1/2] Missing number --- LeetCode/MissingNumber.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 LeetCode/MissingNumber.java diff --git a/LeetCode/MissingNumber.java b/LeetCode/MissingNumber.java new file mode 100644 index 0000000..216de09 --- /dev/null +++ b/LeetCode/MissingNumber.java @@ -0,0 +1,24 @@ +import java.util.Arrays; + +public class MissingNumber { + public static void main(String[] args) { + int a[]={0,1,2,4}; + int n=a.length; + int missing=-1; + Arrays.sort(a); + for(int i=0;i Date: Sun, 10 Oct 2021 19:13:58 +0530 Subject: [PATCH 2/2] testing-sort --- GeeksForGeeks/MergeSortWithoutExtraSpace.java | 35 +++++++++++++++++++ LeetCode/MissingNumber.java | 24 ------------- 2 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 GeeksForGeeks/MergeSortWithoutExtraSpace.java delete mode 100644 LeetCode/MissingNumber.java diff --git a/GeeksForGeeks/MergeSortWithoutExtraSpace.java b/GeeksForGeeks/MergeSortWithoutExtraSpace.java new file mode 100644 index 0000000..b4a8fd4 --- /dev/null +++ b/GeeksForGeeks/MergeSortWithoutExtraSpace.java @@ -0,0 +1,35 @@ + +import java.util.Arrays; +import java.util.Collection; + +/** + * MergeSort_2 + */ +//Q MergeSort two Arrays without taking any Extra Space +public class MergeSortWithoutExtraSpace { + + public static void main(String[] args) { + int N = 2, M = 3; + int a1[] = { 10, 12 };// first Input Array + int a2[] = { 5, 18, 20 };//second Input Array + + int i=N-1;//i value will start form total number-1 + int j=0; + //This function will Simple compare the value and swap the value + //if Array1 value is smaller than Array2 it will sawp it. + while(i>=0 && ja2[j]){ + int temp=a1[i]; + a1[i]=a2[j]; + a2[j]=temp; + + + }i--;j++; + } + Arrays.sort(a1);//sort the Array one + Arrays.sort(a2);//Sort the Array two + for(int K=0;K