Skip to content

Commit

Permalink
88. Merge Sorted Array.java
Browse files Browse the repository at this point in the history
  • Loading branch information
SE-MahmoudAbdelaal committed May 29, 2024
1 parent 8adec13 commit a5c21cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class Solution {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.util.Arrays;

class Solution {
public void merge(int[] nums1, int m, int[] nums2, int n) {
int counter=0;
while (counter<n){
nums1[m]=nums2[counter];
m++;
counter++;
}
for (int i = 0; i <nums1.length ; i++) {
for (int j = i+1; j <nums1.length ; j++) {
int tempValue=0;
if (nums1[i]>nums1[j]){
tempValue=nums1[i];
nums1[i]=nums1[j];
nums1[j]=tempValue;
}

}
}
}
}

0 comments on commit a5c21cf

Please sign in to comment.