mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
1. Add build script for Java.
2. Add height limitation for code blocks in extra.css. 3. Fix "节点" to "结点".
This commit is contained in:
@@ -4,11 +4,9 @@
|
||||
* Author: Justin (xiefahit@gmail.com)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 合并左子数组和右子数组
|
||||
* 左子数组区间 [left, mid]
|
||||
* 右子数组区间 [mid + 1, right]
|
||||
*/
|
||||
/* 合并左子数组和右子数组 */
|
||||
// 左子数组区间 [left, mid]
|
||||
// 右子数组区间 [mid + 1, right]
|
||||
function merge(nums: number[], left: number, mid: number, right: number): void {
|
||||
// 初始化辅助数组
|
||||
let tmp = nums.slice(left, right + 1);
|
||||
|
||||
@@ -12,7 +12,7 @@ class AVLTree {
|
||||
root: TreeNode;
|
||||
/*构造函数*/
|
||||
constructor() {
|
||||
this.root = null; //根节点
|
||||
this.root = null; //根结点
|
||||
}
|
||||
|
||||
/* 获取结点高度 */
|
||||
@@ -45,7 +45,7 @@ class AVLTree {
|
||||
// 更新结点高度
|
||||
this.updateHeight(node);
|
||||
this.updateHeight(child);
|
||||
// 返回旋转后子树的根节点
|
||||
// 返回旋转后子树的根结点
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class AVLTree {
|
||||
// 更新结点高度
|
||||
this.updateHeight(node);
|
||||
this.updateHeight(child);
|
||||
// 返回旋转后子树的根节点
|
||||
// 返回旋转后子树的根结点
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class AVLTree {
|
||||
this.updateHeight(node); // 更新结点高度
|
||||
/* 2. 执行旋转操作,使该子树重新恢复平衡 */
|
||||
node = this.rotate(node);
|
||||
// 返回子树的根节点
|
||||
// 返回子树的根结点
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class AVLTree {
|
||||
this.updateHeight(node); // 更新结点高度
|
||||
/* 2. 执行旋转操作,使该子树重新恢复平衡 */
|
||||
node = this.rotate(node);
|
||||
// 返回子树的根节点
|
||||
// 返回子树的根结点
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ function hierOrder(root: TreeNode | null): number[] {
|
||||
const list: number[] = [];
|
||||
while (queue.length) {
|
||||
let node = queue.shift() as TreeNode; // 队列出队
|
||||
list.push(node.val); // 保存结点
|
||||
list.push(node.val); // 保存结点值
|
||||
if (node.left) {
|
||||
queue.push(node.left); // 左子结点入队
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user