Compare commits

...

4 Commits

Author SHA1 Message Date
c07a658f26 更新 workspace.xml 2023-09-05 17:44:42 +08:00
4b4c9344b5 更新 Solution.java 2023-09-05 17:44:34 +08:00
49b6b07473 更新 test.java 2023-09-05 17:44:32 +08:00
316b795e02 更新 .gitignore 2023-09-05 17:44:22 +08:00
4 changed files with 78 additions and 26 deletions

3
.gitignore vendored
View File

@@ -50,11 +50,10 @@ bin/
*.zip *.zip
*.tar.gz *.tar.gz
*.rar *.rar
.idea/*
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
replay_pid* replay_pid*
>>>>>>> gitea/master >>>>>>> gitea/master
.idea/*
.idea/workspace.xml

55
.idea/workspace.xml generated
View File

@@ -4,7 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="45f625e1-36c7-4942-8f7c-ba3ebe9a7d53" name="变更" comment="" /> <list default="true" id="45f625e1-36c7-4942-8f7c-ba3ebe9a7d53" name="变更" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/solution/Solution.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/solution/Solution.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/solution/test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/solution/test.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -29,22 +34,23 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;, "RunOnceActivity.OpenProjectViewOnStart": "true",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;, "WebServerToolWindowFactoryState": "false",
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, "node.js.detected.package.eslint": "true",
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, "node.js.detected.package.tslint": "true",
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, "node.js.selected.package.eslint": "(autodetect)",
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, "node.js.selected.package.tslint": "(autodetect)",
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, "nodejs_package_manager_path": "npm",
&quot;project.structure.last.edited&quot;: &quot;模块&quot;, "project.structure.last.edited": "模块",
&quot;project.structure.proportion&quot;: &quot;0.0&quot;, "project.structure.proportion": "0.0",
&quot;project.structure.side.proportion&quot;: &quot;0.0&quot;, "project.structure.side.proportion": "0.0",
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot; "settings.editor.selected.configurable": "preferences.lookFeel",
"vue.rearranger.settings.migration": "true"
} }
}</component> }]]></component>
<component name="RunManager"> <component name="RunManager">
<configuration name="test" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="test" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="solution.test" /> <option name="MAIN_CLASS_NAME" value="solution.test" />
@@ -75,10 +81,27 @@
<updated>1693822719192</updated> <updated>1693822719192</updated>
<workItem from="1693822720224" duration="5742000" /> <workItem from="1693822720224" duration="5742000" />
<workItem from="1693895305007" duration="5358000" /> <workItem from="1693895305007" duration="5358000" />
<workItem from="1693900694533" duration="6345000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/solution/Solution.java</url>
<line>105</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/solution/Solution.java</url>
<line>83</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project> </project>

View File

@@ -1,9 +1,7 @@
package solution; package solution;
import java.util.HashMap; import java.util.*;
import java.util.HashSet; import java.util.stream.Collectors;
import java.util.Map;
import java.util.Set;
public class Solution { public class Solution {
@@ -81,8 +79,30 @@ public class Solution {
} }
return candidate; return candidate;
} }
//合并数组冒泡排序实现
public 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];
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 j = 0; j < nums.length; j++) {
if (i != j) {
if (nums[i] < nums[j]){
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
}
nums1 = nums;
String result = Arrays.stream(nums1).mapToObj(String::valueOf).collect(Collectors.joining(",", "[", "]"));
System.out.println(result);
} }
} }

View File

@@ -1,11 +1,21 @@
package solution; package solution;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
public class test { public class test {
public static void main(String[] args) { public static void main(String[] args) {
int[] nums1 = new int[]{1,2,3,0,0,0};
int m = 3;
int[] nums2 = new int[]{2,5,6};
int n = 3;
// int[] nums1 = new int[]{1};
// int m = 1;
// int[] nums2 = new int[]{};
// int n = 0;
Solution.merge(nums1,m,nums2,n);
} }
} }