File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 7
7
<groupId >me.anduo</groupId >
8
8
<artifactId >jiuzhang</artifactId >
9
9
<version >1.0-SNAPSHOT</version >
10
-
10
+ <properties >
11
+ <maven .compiler.source>11</maven .compiler.source>
12
+ <maven .compiler.target>11</maven .compiler.target>
13
+ </properties >
11
14
<build >
12
15
<sourceDirectory >src</sourceDirectory >
13
16
<plugins >
14
17
<plugin >
15
- <artifactId >maven-compiler-plugin</artifactId >
16
- <configuration >
17
- <source >1.8</source >
18
- <target >1.8</target >
19
- </configuration >
18
+ <groupId >org.apache.maven.plugins</groupId >
19
+ <artifactId >maven-compiler-plugin</artifactId >
20
+ <version >3.8.1</version >
21
+ <configuration >
22
+ <source >11</source >
23
+ <target >11</target >
24
+ </configuration >
20
25
</plugin >
21
26
</plugins >
22
27
</build >
Original file line number Diff line number Diff line change
1
+ package solutions ;
2
+
3
+ import java .util .HashMap ;
4
+
5
+ public class P0001_Two_Sum {
6
+
7
+ public int [] twoSum (int [] nums , int target ) {
8
+ var remainIndexMap = new HashMap <Integer , Integer >();
9
+ for (int i = 0 ; i < nums .length ; i ++) {
10
+ if (remainIndexMap .containsKey (nums [i ])) {
11
+ return new int []{remainIndexMap .get (nums [i ]), i };
12
+ }
13
+ remainIndexMap .put (target - nums [i ], i );
14
+ }
15
+ return new int []{-1 , -1 };
16
+ }
17
+
18
+ }
You can’t perform that action at this time.
0 commit comments