Many bug fixes and improvements (#1270)

* Add Ruby and Kotlin icons
Add the avatar of @curtishd

* Update README

* Synchronize zh-hant and zh versions.

* Translate the pythontutor blocks to traditional Chinese

* Fix en/mkdocs.yml

* Update the landing page of the en version.

* Fix the Dockerfile

* Refine the en landingpage

* Fix en landing page

* Reset the README.md
This commit is contained in:
Yudong Jin
2024-04-11 20:18:19 +08:00
committed by GitHub
parent 07977184ad
commit b2f0d4603d
192 changed files with 2382 additions and 1196 deletions
@@ -10,7 +10,13 @@ import utils.TreeNode
import utils.printTree
/* 構建二元樹:分治 */
fun dfs(preorder: IntArray, inorderMap: Map<Int?, Int?>, i: Int, l: Int, r: Int): TreeNode? {
fun dfs(
preorder: IntArray,
inorderMap: Map<Int?, Int?>,
i: Int,
l: Int,
r: Int
): TreeNode? {
// 子樹區間為空時終止
if (r - l < 0) return null
// 初始化根節點
@@ -28,7 +34,7 @@ fun dfs(preorder: IntArray, inorderMap: Map<Int?, Int?>, i: Int, l: Int, r: Int)
/* 構建二元樹 */
fun buildTree(preorder: IntArray, inorder: IntArray): TreeNode? {
// 初始化雜湊表,儲存 inorder 元素到索引的對映
val inorderMap: MutableMap<Int?, Int?> = HashMap()
val inorderMap = HashMap<Int?, Int?>()
for (i in inorder.indices) {
inorderMap[inorder[i]] = i
}
@@ -40,8 +46,8 @@ fun buildTree(preorder: IntArray, inorder: IntArray): TreeNode? {
fun main() {
val preorder = intArrayOf(3, 9, 2, 1, 7)
val inorder = intArrayOf(9, 3, 1, 2, 7)
println("前序走訪 = " + preorder.contentToString())
println("中序走訪 = " + inorder.contentToString())
println("前序走訪 = ${preorder.contentToString()}")
println("中序走訪 = ${inorder.contentToString()}")
val root = buildTree(preorder, inorder)
println("構建的二元樹為:")
@@ -9,7 +9,7 @@ package chapter_divide_and_conquer.hanota
/* 移動一個圓盤 */
fun move(src: MutableList<Int>, tar: MutableList<Int>) {
// 從 src 頂部拿出一個圓盤
val pan: Int = src.removeAt(src.size - 1)
val pan = src.removeAt(src.size - 1)
// 將圓盤放入 tar 頂部
tar.add(pan)
}
@@ -39,9 +39,9 @@ fun solveHanota(A: MutableList<Int>, B: MutableList<Int>, C: MutableList<Int>) {
/* Driver Code */
fun main() {
// 串列尾部是柱子頂部
val A: MutableList<Int> = ArrayList(mutableListOf(5, 4, 3, 2, 1))
val B: MutableList<Int> = ArrayList()
val C: MutableList<Int> = ArrayList()
val A = mutableListOf(5, 4, 3, 2, 1)
val B = mutableListOf<Int>()
val C = mutableListOf<Int>()
println("初始狀態下:")
println("A = $A")
println("B = $B")
@@ -53,4 +53,4 @@ fun main() {
println("A = $A")
println("B = $B")
println("C = $C")
}
}