Compare commits
9 Commits
a83429a6b7
...
8f15fee32e
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f15fee32e | |||
| 0eb5aa8e9e | |||
| 1bdd2f6973 | |||
| 239dcec5ae | |||
| 85497363cf | |||
| a264682bc4 | |||
| 05b608b6d9 | |||
| 22bc22261f | |||
| bf2e20cde9 |
@@ -81,31 +81,33 @@ public class Solution {
|
|||||||
}
|
}
|
||||||
//合并数组冒泡排序实现
|
//合并数组冒泡排序实现
|
||||||
public static void merge(int[] nums1, int m, int[] nums2, int n) {
|
public static void merge(int[] nums1, int m, int[] nums2, int n) {
|
||||||
int[] nums= new int[m + n];
|
System.arraycopy(nums2, 0, nums1, m, n);
|
||||||
for (int i = 0; i < m + n; i++) {
|
|
||||||
if (i < m){
|
|
||||||
nums[i] = nums1[i];
|
|
||||||
} else {
|
|
||||||
nums[i] = nums2[i - m];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 冒泡排序
|
// 冒泡排序
|
||||||
for (int i = 0; i < nums.length; i++) {
|
for (int i = 0; i < nums1.length; i++) {
|
||||||
for (int j = 0; j < nums.length; j++) {
|
for (int j = 0; j < nums1.length; j++) {
|
||||||
if (i != j) {
|
if (i != j) {
|
||||||
if (nums[i] < nums[j]){
|
if (nums1[i] < nums1[j]){
|
||||||
int temp = nums[i];
|
int temp = nums1[i];
|
||||||
nums[i] = nums[j];
|
nums1[i] = nums1[j];
|
||||||
nums[j] = temp;
|
nums1[j] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nums1 = nums;
|
|
||||||
String result = Arrays.stream(nums1).mapToObj(String::valueOf).collect(Collectors.joining(",", "[", "]"));
|
String result = Arrays.stream(nums1).mapToObj(String::valueOf).collect(Collectors.joining(",", "[", "]"));
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
public static int removeElement(int[] nums, int val) {
|
||||||
|
for (int i = 0; i < nums.length; i++) {
|
||||||
|
if (val == nums[i]){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nums.length;
|
||||||
|
}
|
||||||
|
=======
|
||||||
// public static String longestCommonPrefix(String[] strs) {
|
// public static String longestCommonPrefix(String[] strs) {
|
||||||
// int index = 0;
|
// int index = 0;
|
||||||
// StringBuilder temp = new StringBuilder();
|
// StringBuilder temp = new StringBuilder();
|
||||||
@@ -157,4 +159,5 @@ public class Solution {
|
|||||||
return strs[0];
|
return strs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
>>>>>>> a83429a6b794491f269fccaa74b710ca4abc514b
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user