Format the Java codes with the Reat Hat extension.

This commit is contained in:
krahets
2023-04-14 00:12:10 +08:00
parent 7273ee24e8
commit f8513455b5
39 changed files with 195 additions and 205 deletions

View File

@@ -42,11 +42,11 @@ public class binary_search {
// 未找到目标元素,返回 -1
return -1;
}
public static void main(String[] args) {
int target = 6;
int[] nums = { 1, 3, 6, 8, 12, 15, 23, 67, 70, 92 };
/* 二分查找(双闭区间) */
int index = binarySearch(nums, target);
System.out.println("目标元素 6 的索引 = " + index);

View File

@@ -32,7 +32,7 @@ public class hashing_search {
// 初始化哈希表
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
map.put(nums[i], i); // key: 元素value: 索引
map.put(nums[i], i); // key: 元素value: 索引
}
int index = hashingSearchArray(map, target);
System.out.println("目标元素 3 的索引 = " + index);
@@ -42,7 +42,7 @@ public class hashing_search {
// 初始化哈希表
Map<Integer, ListNode> map1 = new HashMap<>();
while (head != null) {
map1.put(head.val, head); // key: 节点值value: 节点
map1.put(head.val, head); // key: 节点值value: 节点
head = head.next;
}
ListNode node = hashingSearchLinkedList(map1, target);