first commit 3.8

This commit is contained in:
zhangsan 2025-03-08 10:33:08 +08:00
commit 5f25a34e75
4 changed files with 90 additions and 0 deletions

36
.gitignore vendored Normal file
View 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
View 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>

View 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};
}
}

View 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]);
}
}
}