first commit 3.8
This commit is contained in:
parent
5f25a34e75
commit
4d6b623f9a
@ -1,15 +0,0 @@
|
||||
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};
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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