-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8adec13
commit a5c21cf
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
Top Interview 150-leetcode/easy/88. Merge Sorted Array/27. Remove Element/src/Solution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package PACKAGE_NAME;public class Solution { | ||
} |
23 changes: 23 additions & 0 deletions
23
Top Interview 150-leetcode/easy/88. Merge Sorted Array/88. Merge Sorted Array.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
} | ||
} | ||
} |