first commit 3.8
This commit is contained in:
commit
5f25a34e75
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# 忽略 IDE 相关文件
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# 忽略 Maven 构建输出
|
||||||
|
target/
|
||||||
|
**/target/
|
||||||
|
**/*.class
|
||||||
|
**/*.jar
|
||||||
|
**/*.war
|
||||||
|
**/*.ear
|
||||||
|
|
||||||
|
# 忽略 Gradle 构建输出
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
out/
|
||||||
|
|
||||||
|
# 忽略日志文件
|
||||||
|
*.log
|
||||||
|
logs/
|
||||||
|
|
||||||
|
# 忽略系统文件
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# 忽略本地配置文件(如数据库配置)
|
||||||
|
*.properties
|
||||||
|
*.yml
|
||||||
|
*.yaml
|
||||||
|
|
||||||
|
# 忽略其他临时文件
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
23
pom.xml
Normal file
23
pom.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>LeetCodeSolutions</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.12</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
15
src/main/java/edu/whut/hash/TwoSum.java
Normal file
15
src/main/java/edu/whut/hash/TwoSum.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package edu.whut.hash;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 题目:两数之和 (Two Sum)
|
||||||
|
* 描述:给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那两个整数,并返回它们的数组下标。
|
||||||
|
* 链接:https://leetcode.cn/problems/two-sum/
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TwoSum {
|
||||||
|
public int[] twoSum(int[] nums, int target) {
|
||||||
|
// 实现代码
|
||||||
|
return new int[]{0, 1};
|
||||||
|
}
|
||||||
|
}
|
16
src/test/java/edu/whut/hash/HashAlgorithmsTest.java
Normal file
16
src/test/java/edu/whut/hash/HashAlgorithmsTest.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package edu.whut.hash;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class HashAlgorithmsTest {
|
||||||
|
@Test
|
||||||
|
public void testTwoSum() {
|
||||||
|
TwoSum solution = new TwoSum();
|
||||||
|
int[] nums = {2, 7, 11, 15};
|
||||||
|
int target = 9;
|
||||||
|
int[] result = solution.twoSum(nums, target);
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
System.out.println(result[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user