mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 14:27:26 +08:00
Add build script for JS and TS codes.
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
* Author: IsChristina (christinaxia77@foxmail.com)
|
||||
*/
|
||||
|
||||
/* 随机访问元素 */
|
||||
/* 随机返回一个数组元素 */
|
||||
function randomAccess(nums) {
|
||||
// 在区间 [0, nums.length) 中随机抽取一个数字
|
||||
const random_index = Math.floor(Math.random() * nums.length);
|
||||
|
@ -44,7 +44,7 @@ class LinkedListStack {
|
||||
/* 访问栈顶元素 */
|
||||
peek() {
|
||||
if (!this.#stackPeek)
|
||||
throw new Error("栈为空!");
|
||||
throw new Error("栈为空");
|
||||
return this.#stackPeek.val;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user