mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
Polish the chapter of array and linkedlist
This commit is contained in:
@ -10,7 +10,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class array {
|
||||
/* 随机返回一个数组元素 */
|
||||
/* 随机访问元素 */
|
||||
static int randomAccess(int[] nums) {
|
||||
// 在区间 [0, nums.length) 中随机抽取一个数字
|
||||
int randomIndex = ThreadLocalRandom.current().nextInt(0, nums.length);
|
||||
|
||||
@ -11,8 +11,8 @@ import java.util.*;
|
||||
/* 双向链表节点 */
|
||||
class ListNode {
|
||||
int val; // 节点值
|
||||
ListNode next; // 后继节点引用(指针)
|
||||
ListNode prev; // 前驱节点引用(指针)
|
||||
ListNode next; // 后继节点引用
|
||||
ListNode prev; // 前驱节点引用
|
||||
|
||||
ListNode(int val) {
|
||||
this.val = val;
|
||||
|
||||
Reference in New Issue
Block a user