diff --git a/codes/snippets/chapter_array_and_linkedlist/linked_list.md b/codes/snippets/chapter_array_and_linkedlist/linked_list.md index 0435e423f..b5163e888 100644 --- a/codes/snippets/chapter_array_and_linkedlist/linked_list.md +++ b/codes/snippets/chapter_array_and_linkedlist/linked_list.md @@ -28,8 +28,8 @@ class ListNode { ```csharp title="" /* 链表节点类 */ class ListNode(int x) { //构造函数 - int val = x; // 节点值 - ListNode? next; // 指向下一节点的引用 + public int val = x; // 节点值 + public ListNode? next; // 指向下一节点的引用 } ``` @@ -264,7 +264,7 @@ n3.next = n4; ``` ```dart title="linked_list.dart" -/* 初始化链表 1 -> 3 -> 2 -> 5 -> 4 */\ +/* 初始化链表 1 -> 3 -> 2 -> 5 -> 4 */ // 初始化各个节点 ListNode n0 = ListNode(1); ListNode n1 = ListNode(3); @@ -375,9 +375,9 @@ class ListNode { ```csharp title="" /* 双向链表节点类 */ class ListNode(int x) { // 构造函数 - int val = x; // 节点值 - ListNode next; // 指向后继节点的引用 - ListNode prev; // 指向前驱节点的引用 + public int val = x; // 节点值 + public ListNode? next; // 指向后继节点的引用 + public ListNode? prev; // 指向前驱节点的引用 } ``` diff --git a/codes/snippets/chapter_array_and_linkedlist/list.md b/codes/snippets/chapter_array_and_linkedlist/list.md index a8510672b..e0903ad8e 100644 --- a/codes/snippets/chapter_array_and_linkedlist/list.md +++ b/codes/snippets/chapter_array_and_linkedlist/list.md @@ -79,7 +79,7 @@ List nums = [1, 3, 2, 5, 4]; // 无初始值 let nums1: Vec = Vec::new(); // 有初始值 -let nums: Vec = vec![1, 3, 2, 5, 4]; +let mut nums: Vec = vec![1, 3, 2, 5, 4]; ``` ```c title="list.c" @@ -404,10 +404,10 @@ nums.add(5); nums.add(4); /* 在中间插入元素 */ -nums.add(3, 6); // 在索引 3 处插入数字 6 +nums.add(3, 6); // 在索引 3 处插入数字 6 /* 删除元素 */ -nums.remove(3); // 删除索引 3 处的元素 +nums.removeAt(3); // 删除索引 3 处的元素 ``` ```ruby title="list.rb" diff --git a/codes/snippets/chapter_backtracking/backtracking_algorithm.md b/codes/snippets/chapter_backtracking/backtracking_algorithm.md index a1c424bf4..5b9842d38 100644 --- a/codes/snippets/chapter_backtracking/backtracking_algorithm.md +++ b/codes/snippets/chapter_backtracking/backtracking_algorithm.md @@ -1,6 +1,6 @@ ```python title="" -def backtrack(state: State, choices: list[choice], res: list[state]): +def backtrack(state: State, choices: list[Choice], res: list[State]): """回溯算法框架""" # 判断是否为解 if is_solution(state): @@ -30,7 +30,7 @@ void backtrack(State *state, vector &choices, vector &res) { return; } // 遍历所有选择 - for (Choice choice : choices) { + for (Choice *choice : choices) { // 剪枝:判断选择是否合法 if (isValid(state, choice)) { // 尝试:做出选择,更新状态 @@ -189,7 +189,7 @@ function backtrack(state: State, choices: Choice[], res: State[]): void { ```dart title="" /* 回溯算法框架 */ -void backtrack(State state, List, List res) { +void backtrack(State state, List choices, List res) { // 判断是否为解 if (isSolution(state)) { // 记录解 diff --git a/codes/snippets/chapter_computational_complexity/space_complexity.md b/codes/snippets/chapter_computational_complexity/space_complexity.md index d8b044698..a38c16ac3 100644 --- a/codes/snippets/chapter_computational_complexity/space_complexity.md +++ b/codes/snippets/chapter_computational_complexity/space_complexity.md @@ -196,7 +196,7 @@ function algorithm(n: number): number { // 输入数据 /* 类 */ class Node { int val; - Node next; + Node? next; Node(this.val, [this.next]); } @@ -332,8 +332,9 @@ void algorithm(int n) { void algorithm(int n) { int a = 0; // O(1) int[] b = new int[10000]; // O(1) - if (n > 10) + if (n > 10) { int[] nums = new int[n]; // O(n) + } } ``` @@ -353,7 +354,7 @@ func algorithm(n int) { b := make([]int, 10000) // O(1) var nums []int if n > 10 { - nums := make([]int, n) // O(n) + nums = make([]int, n) // O(n) } fmt.Println(a, b, nums) } @@ -413,8 +414,9 @@ fn algorithm(n: i32) { void algorithm(int n) { int a = 0; // O(1) int b[10000]; // O(1) - if (n > 10) - int nums[n] = {0}; // O(n) + if (n > 10) { + int nums[n]; // O(n) + } } ``` @@ -613,7 +615,7 @@ fn function() -> i32 { return 0; } /* 循环的空间复杂度为 O(1) */ -fn loop(n: i32) { +fn for_loop(n: i32) { for i in 0..n { function(); } diff --git a/codes/snippets/chapter_computational_complexity/time_complexity.md b/codes/snippets/chapter_computational_complexity/time_complexity.md index 16a46f973..a77b8b0c7 100644 --- a/codes/snippets/chapter_computational_complexity/time_complexity.md +++ b/codes/snippets/chapter_computational_complexity/time_complexity.md @@ -774,10 +774,10 @@ def algorithm(n) a = 1 # +0(技巧 1) a = a + n # +0(技巧 1) # +n(技巧 2) - (0...(5 * n + 1)).each do { puts 0 } + (0...(5 * n + 1)).each { puts 0 } # +n*n(技巧 3) (0...(2 * n)).each do - (0...(n + 1)).each do { puts 0 } + (0...(n + 1)).each { puts 0 } end end ``` diff --git a/codes/snippets/chapter_data_structure/basic_data_types.md b/codes/snippets/chapter_data_structure/basic_data_types.md index 29f70add0..134fdaf15 100644 --- a/codes/snippets/chapter_data_structure/basic_data_types.md +++ b/codes/snippets/chapter_data_structure/basic_data_types.md @@ -96,7 +96,7 @@ val bools = BooleanArray(5) ```ruby title="" # Ruby 的列表可以自由存储各种基本数据类型和对象引用 -data = [0, 0.0, 'a', false, ListNode(0)] +data = [0, 0.0, 'a', false, ListNode.new(0)] ``` diff --git a/codes/snippets/chapter_hashing/hash_map.md b/codes/snippets/chapter_hashing/hash_map.md index ba875d260..f8ae2ad72 100644 --- a/codes/snippets/chapter_hashing/hash_map.md +++ b/codes/snippets/chapter_hashing/hash_map.md @@ -184,7 +184,7 @@ map[10583] = "小鸭"; /* 查询操作 */ // 向哈希表中输入键 key ,得到值 value -String name = map[15937]; +String? name = map[15937]; /* 删除操作 */ // 在哈希表中删除键值对 (key, value) @@ -202,7 +202,7 @@ let mut map: HashMap = HashMap::new(); map.insert(12836, "小哈".to_string()); map.insert(15937, "小啰".to_string()); map.insert(16750, "小算".to_string()); -map.insert(13279, "小法".to_string()); +map.insert(13276, "小法".to_string()); map.insert(10583, "小鸭".to_string()); /* 查询操作 */ diff --git a/codes/snippets/chapter_heap/heap.md b/codes/snippets/chapter_heap/heap.md index 97404fce3..e02b5332e 100644 --- a/codes/snippets/chapter_heap/heap.md +++ b/codes/snippets/chapter_heap/heap.md @@ -71,7 +71,7 @@ bool isEmpty = maxHeap.empty(); /* 输入列表并建堆 */ vector input{1, 3, 2, 5, 4}; -priority_queue, greater> minHeap(input.begin(), input.end()); +minHeap = priority_queue, greater>(input.begin(), input.end()); ``` ```java title="heap.java" diff --git a/en/codes/snippets/chapter_array_and_linkedlist/linked_list.md b/en/codes/snippets/chapter_array_and_linkedlist/linked_list.md index ae5fd27f1..8e102c03f 100644 --- a/en/codes/snippets/chapter_array_and_linkedlist/linked_list.md +++ b/en/codes/snippets/chapter_array_and_linkedlist/linked_list.md @@ -28,8 +28,8 @@ class ListNode { ```csharp title="" /* Linked list node class */ class ListNode(int x) { // Constructor - int val = x; // Node value - ListNode? next; // Reference to the next node + public int val = x; // Node value + public ListNode? next; // Reference to the next node } ``` @@ -264,7 +264,7 @@ n3.next = n4; ``` ```dart title="linked_list.dart" -/* Initialize the linked list 1 -> 3 -> 2 -> 5 -> 4 */\ +/* Initialize the linked list 1 -> 3 -> 2 -> 5 -> 4 */ // Initialize the nodes ListNode n0 = ListNode(1); ListNode n1 = ListNode(3); @@ -375,9 +375,9 @@ class ListNode { ```csharp title="" /* Doubly linked list node class */ class ListNode(int x) { // Constructor - int val = x; // Node value - ListNode next; // Reference to the successor - ListNode prev; // Reference to the predecessor + public int val = x; // Node value + public ListNode? next; // Reference to the successor + public ListNode? prev; // Reference to the predecessor } ``` diff --git a/en/codes/snippets/chapter_array_and_linkedlist/list.md b/en/codes/snippets/chapter_array_and_linkedlist/list.md index d6c188b93..d6705a45f 100644 --- a/en/codes/snippets/chapter_array_and_linkedlist/list.md +++ b/en/codes/snippets/chapter_array_and_linkedlist/list.md @@ -79,7 +79,7 @@ List nums = [1, 3, 2, 5, 4]; // Without initial values let nums1: Vec = Vec::new(); // With initial values -let nums: Vec = vec![1, 3, 2, 5, 4]; +let mut nums: Vec = vec![1, 3, 2, 5, 4]; ``` ```c title="list.c" @@ -404,10 +404,10 @@ nums.add(5); nums.add(4); /* Insert an element in the middle */ -nums.add(3, 6); // Insert 6 at index 3 +nums.add(3, 6); // Insert 6 at index 3 /* Remove an element */ -nums.remove(3); // Remove the element at index 3 +nums.removeAt(3); // Remove the element at index 3 ``` ```ruby title="list.rb" diff --git a/en/codes/snippets/chapter_backtracking/backtracking_algorithm.md b/en/codes/snippets/chapter_backtracking/backtracking_algorithm.md index 742f2b1ad..85e2029d0 100644 --- a/en/codes/snippets/chapter_backtracking/backtracking_algorithm.md +++ b/en/codes/snippets/chapter_backtracking/backtracking_algorithm.md @@ -1,6 +1,6 @@ ```python title="" -def backtrack(state: State, choices: list[choice], res: list[state]): +def backtrack(state: State, choices: list[Choice], res: list[State]): """Backtracking template""" # Check whether the state is a solution if is_solution(state): @@ -30,7 +30,7 @@ void backtrack(State *state, vector &choices, vector &res) { return; } // Try every choice - for (Choice choice : choices) { + for (Choice *choice : choices) { // Prune: check whether the choice is valid if (isValid(state, choice)) { // Try: make the choice and update the state @@ -189,7 +189,7 @@ function backtrack(state: State, choices: Choice[], res: State[]): void { ```dart title="" /* Backtracking template */ -void backtrack(State state, List, List res) { +void backtrack(State state, List choices, List res) { // Check whether the state is a solution if (isSolution(state)) { // Record the solution diff --git a/en/codes/snippets/chapter_computational_complexity/space_complexity.md b/en/codes/snippets/chapter_computational_complexity/space_complexity.md index 4b090cb2d..31f35ac71 100644 --- a/en/codes/snippets/chapter_computational_complexity/space_complexity.md +++ b/en/codes/snippets/chapter_computational_complexity/space_complexity.md @@ -196,7 +196,7 @@ function algorithm(n: number): number { // Input data /* Class */ class Node { int val; - Node next; + Node? next; Node(this.val, [this.next]); } @@ -332,8 +332,9 @@ void algorithm(int n) { void algorithm(int n) { int a = 0; // O(1) int[] b = new int[10000]; // O(1) - if (n > 10) + if (n > 10) { int[] nums = new int[n]; // O(n) + } } ``` @@ -353,7 +354,7 @@ func algorithm(n int) { b := make([]int, 10000) // O(1) var nums []int if n > 10 { - nums := make([]int, n) // O(n) + nums = make([]int, n) // O(n) } fmt.Println(a, b, nums) } @@ -413,8 +414,9 @@ fn algorithm(n: i32) { void algorithm(int n) { int a = 0; // O(1) int b[10000]; // O(1) - if (n > 10) - int nums[n] = {0}; // O(n) + if (n > 10) { + int nums[n]; // O(n) + } } ``` @@ -613,7 +615,7 @@ fn function() -> i32 { return 0; } /* The loop uses O(1) space */ -fn loop(n: i32) { +fn for_loop(n: i32) { for i in 0..n { function(); } diff --git a/en/codes/snippets/chapter_computational_complexity/time_complexity.md b/en/codes/snippets/chapter_computational_complexity/time_complexity.md index 609e7fd68..5ea6975a5 100644 --- a/en/codes/snippets/chapter_computational_complexity/time_complexity.md +++ b/en/codes/snippets/chapter_computational_complexity/time_complexity.md @@ -774,10 +774,10 @@ def algorithm(n) a = 1 # +0 (shortcut 1) a = a + n # +0 (shortcut 1) # +n (shortcut 2) - (0...(5 * n + 1)).each do { puts 0 } + (0...(5 * n + 1)).each { puts 0 } # +n*n (shortcut 3) (0...(2 * n)).each do - (0...(n + 1)).each do { puts 0 } + (0...(n + 1)).each { puts 0 } end end ``` diff --git a/en/codes/snippets/chapter_data_structure/basic_data_types.md b/en/codes/snippets/chapter_data_structure/basic_data_types.md index 83db097c5..d7065eba6 100644 --- a/en/codes/snippets/chapter_data_structure/basic_data_types.md +++ b/en/codes/snippets/chapter_data_structure/basic_data_types.md @@ -96,7 +96,7 @@ val bools = BooleanArray(5) ```ruby title="" # Ruby arrays can hold different basic data types and object references -data = [0, 0.0, 'a', false, ListNode(0)] +data = [0, 0.0, 'a', false, ListNode.new(0)] ``` diff --git a/en/codes/snippets/chapter_hashing/hash_map.md b/en/codes/snippets/chapter_hashing/hash_map.md index c1e4a28cf..63adeb264 100644 --- a/en/codes/snippets/chapter_hashing/hash_map.md +++ b/en/codes/snippets/chapter_hashing/hash_map.md @@ -184,7 +184,7 @@ map[10583] = "小鸭"; /* Lookup */ // Look up key in the hash table to obtain value -String name = map[15937]; +String? name = map[15937]; /* Deletion */ // Remove a key-value pair (key, value) from the hash table @@ -202,7 +202,7 @@ let mut map: HashMap = HashMap::new(); map.insert(12836, "小哈".to_string()); map.insert(15937, "小啰".to_string()); map.insert(16750, "小算".to_string()); -map.insert(13279, "小法".to_string()); +map.insert(13276, "小法".to_string()); map.insert(10583, "小鸭".to_string()); /* Lookup */ diff --git a/en/codes/snippets/chapter_heap/heap.md b/en/codes/snippets/chapter_heap/heap.md index 89fb6310e..b06e780f3 100644 --- a/en/codes/snippets/chapter_heap/heap.md +++ b/en/codes/snippets/chapter_heap/heap.md @@ -71,7 +71,7 @@ bool isEmpty = maxHeap.empty(); /* Build a heap from a list */ vector input{1, 3, 2, 5, 4}; -priority_queue, greater> minHeap(input.begin(), input.end()); +minHeap = priority_queue, greater>(input.begin(), input.end()); ``` ```java title="heap.java" diff --git a/ja/codes/snippets/chapter_array_and_linkedlist/linked_list.md b/ja/codes/snippets/chapter_array_and_linkedlist/linked_list.md index d0474d6a0..ef34436b9 100644 --- a/ja/codes/snippets/chapter_array_and_linkedlist/linked_list.md +++ b/ja/codes/snippets/chapter_array_and_linkedlist/linked_list.md @@ -28,8 +28,8 @@ class ListNode { ```csharp title="" /* 連結リストのノードクラス */ class ListNode(int x) { //コンストラクタ - int val = x; // ノードの値 - ListNode? next; // 次のノードへの参照 + public int val = x; // ノードの値 + public ListNode? next; // 次のノードへの参照 } ``` @@ -264,7 +264,7 @@ n3.next = n4; ``` ```dart title="linked_list.dart" -/* 連結リスト 1 -> 3 -> 2 -> 5 -> 4 を初期化 */\ +/* 連結リスト 1 -> 3 -> 2 -> 5 -> 4 を初期化 */ // 各ノードを初期化 ListNode n0 = ListNode(1); ListNode n1 = ListNode(3); @@ -375,9 +375,9 @@ class ListNode { ```csharp title="" /* 双方向連結リストのノードクラス */ class ListNode(int x) { // コンストラクタ - int val = x; // ノードの値 - ListNode next; // 後続ノードへの参照 - ListNode prev; // 先行ノードへの参照 + public int val = x; // ノードの値 + public ListNode? next; // 後続ノードへの参照 + public ListNode? prev; // 先行ノードへの参照 } ``` diff --git a/ja/codes/snippets/chapter_array_and_linkedlist/list.md b/ja/codes/snippets/chapter_array_and_linkedlist/list.md index 85bb8823f..74ace4a03 100644 --- a/ja/codes/snippets/chapter_array_and_linkedlist/list.md +++ b/ja/codes/snippets/chapter_array_and_linkedlist/list.md @@ -79,7 +79,7 @@ List nums = [1, 3, 2, 5, 4]; // 初期値なし let nums1: Vec = Vec::new(); // 初期値あり -let nums: Vec = vec![1, 3, 2, 5, 4]; +let mut nums: Vec = vec![1, 3, 2, 5, 4]; ``` ```c title="list.c" @@ -404,10 +404,10 @@ nums.add(5); nums.add(4); /* 途中に要素を挿入 */ -nums.add(3, 6); // インデックス 3 に数値 6 を挿入 +nums.add(3, 6); // インデックス 3 に数値 6 を挿入 /* 要素を削除 */ -nums.remove(3); // インデックス 3 の要素を削除 +nums.removeAt(3); // インデックス 3 の要素を削除 ``` ```ruby title="list.rb" diff --git a/ja/codes/snippets/chapter_backtracking/backtracking_algorithm.md b/ja/codes/snippets/chapter_backtracking/backtracking_algorithm.md index a5430a49a..58e431dd8 100644 --- a/ja/codes/snippets/chapter_backtracking/backtracking_algorithm.md +++ b/ja/codes/snippets/chapter_backtracking/backtracking_algorithm.md @@ -1,6 +1,6 @@ ```python title="" -def backtrack(state: State, choices: list[choice], res: list[state]): +def backtrack(state: State, choices: list[Choice], res: list[State]): """バックトラッキングの基本形""" # 解かどうかを判定 if is_solution(state): @@ -30,7 +30,7 @@ void backtrack(State *state, vector &choices, vector &res) { return; } // すべての選択肢を調べる - for (Choice choice : choices) { + for (Choice *choice : choices) { // 枝刈り:選択が有効かを判定 if (isValid(state, choice)) { // 試行:選択して状態を更新 @@ -189,7 +189,7 @@ function backtrack(state: State, choices: Choice[], res: State[]): void { ```dart title="" /* バックトラッキングの基本形 */ -void backtrack(State state, List, List res) { +void backtrack(State state, List choices, List res) { // 解かどうかを判定 if (isSolution(state)) { // 解を記録 diff --git a/ja/codes/snippets/chapter_computational_complexity/space_complexity.md b/ja/codes/snippets/chapter_computational_complexity/space_complexity.md index ba2668605..09ac2ff7d 100644 --- a/ja/codes/snippets/chapter_computational_complexity/space_complexity.md +++ b/ja/codes/snippets/chapter_computational_complexity/space_complexity.md @@ -196,7 +196,7 @@ function algorithm(n: number): number { // 入力データ /* クラス */ class Node { int val; - Node next; + Node? next; Node(this.val, [this.next]); } @@ -332,8 +332,9 @@ void algorithm(int n) { void algorithm(int n) { int a = 0; // O(1) int[] b = new int[10000]; // O(1) - if (n > 10) + if (n > 10) { int[] nums = new int[n]; // O(n) + } } ``` @@ -353,7 +354,7 @@ func algorithm(n int) { b := make([]int, 10000) // O(1) var nums []int if n > 10 { - nums := make([]int, n) // O(n) + nums = make([]int, n) // O(n) } fmt.Println(a, b, nums) } @@ -413,8 +414,9 @@ fn algorithm(n: i32) { void algorithm(int n) { int a = 0; // O(1) int b[10000]; // O(1) - if (n > 10) - int nums[n] = {0}; // O(n) + if (n > 10) { + int nums[n]; // O(n) + } } ``` @@ -613,7 +615,7 @@ fn function() -> i32 { return 0; } /* ループの空間計算量は O(1) */ -fn loop(n: i32) { +fn for_loop(n: i32) { for i in 0..n { function(); } diff --git a/ja/codes/snippets/chapter_computational_complexity/time_complexity.md b/ja/codes/snippets/chapter_computational_complexity/time_complexity.md index 35b36c33d..60b4a6ce8 100644 --- a/ja/codes/snippets/chapter_computational_complexity/time_complexity.md +++ b/ja/codes/snippets/chapter_computational_complexity/time_complexity.md @@ -774,10 +774,10 @@ def algorithm(n) a = 1 # +0(工夫 1) a = a + n # +0(工夫 1) # +n(工夫 2) - (0...(5 * n + 1)).each do { puts 0 } + (0...(5 * n + 1)).each { puts 0 } # +n*n(工夫 3) (0...(2 * n)).each do - (0...(n + 1)).each do { puts 0 } + (0...(n + 1)).each { puts 0 } end end ``` diff --git a/ja/codes/snippets/chapter_data_structure/basic_data_types.md b/ja/codes/snippets/chapter_data_structure/basic_data_types.md index 71b4757c2..bdf98d700 100644 --- a/ja/codes/snippets/chapter_data_structure/basic_data_types.md +++ b/ja/codes/snippets/chapter_data_structure/basic_data_types.md @@ -96,7 +96,7 @@ val bools = BooleanArray(5) ```ruby title="" # Ruby のリストには、さまざまな基本データ型やオブジェクトへの参照を自由に格納できる -data = [0, 0.0, 'a', false, ListNode(0)] +data = [0, 0.0, 'a', false, ListNode.new(0)] ``` diff --git a/ja/codes/snippets/chapter_hashing/hash_map.md b/ja/codes/snippets/chapter_hashing/hash_map.md index 5b13ebcec..4a2420506 100644 --- a/ja/codes/snippets/chapter_hashing/hash_map.md +++ b/ja/codes/snippets/chapter_hashing/hash_map.md @@ -184,7 +184,7 @@ map[10583] = "小鸭"; /* 照会操作 */ // キー key を入力して値 value を取得 -String name = map[15937]; +String? name = map[15937]; /* 削除操作 */ // ハッシュテーブルからペア (key, value) を削除 @@ -202,7 +202,7 @@ let mut map: HashMap = HashMap::new(); map.insert(12836, "小哈".to_string()); map.insert(15937, "小啰".to_string()); map.insert(16750, "小算".to_string()); -map.insert(13279, "小法".to_string()); +map.insert(13276, "小法".to_string()); map.insert(10583, "小鸭".to_string()); /* 照会操作 */ diff --git a/ja/codes/snippets/chapter_heap/heap.md b/ja/codes/snippets/chapter_heap/heap.md index 26dfab83b..511d7b632 100644 --- a/ja/codes/snippets/chapter_heap/heap.md +++ b/ja/codes/snippets/chapter_heap/heap.md @@ -71,7 +71,7 @@ bool isEmpty = maxHeap.empty(); /* リストを入力してヒープを構築 */ vector input{1, 3, 2, 5, 4}; -priority_queue, greater> minHeap(input.begin(), input.end()); +minHeap = priority_queue, greater>(input.begin(), input.end()); ``` ```java title="heap.java" diff --git a/ko/codes/snippets/chapter_array_and_linkedlist/linked_list.md b/ko/codes/snippets/chapter_array_and_linkedlist/linked_list.md index 3d24c437a..fb2b6e5fd 100644 --- a/ko/codes/snippets/chapter_array_and_linkedlist/linked_list.md +++ b/ko/codes/snippets/chapter_array_and_linkedlist/linked_list.md @@ -28,8 +28,8 @@ class ListNode { ```csharp title="" /* 연결 리스트 노드 클래스 */ class ListNode(int x) { //생성자 - int val = x; // 노드 값 - ListNode? next; // 다음 노드를 가리키는 참조 + public int val = x; // 노드 값 + public ListNode? next; // 다음 노드를 가리키는 참조 } ``` @@ -264,7 +264,7 @@ n3.next = n4; ``` ```dart title="linked_list.dart" -/* 연결 리스트 1 -> 3 -> 2 -> 5 -> 4 초기화 */\ +/* 연결 리스트 1 -> 3 -> 2 -> 5 -> 4 초기화 */ // 각 노드 초기화 ListNode n0 = ListNode(1); ListNode n1 = ListNode(3); @@ -375,9 +375,9 @@ class ListNode { ```csharp title="" /* 이중 연결 리스트 노드 클래스 */ class ListNode(int x) { // 생성자 - int val = x; // 노드 값 - ListNode next; // 후속 노드를 가리키는 참조 - ListNode prev; // 선행 노드를 가리키는 참조 + public int val = x; // 노드 값 + public ListNode? next; // 후속 노드를 가리키는 참조 + public ListNode? prev; // 선행 노드를 가리키는 참조 } ``` diff --git a/ko/codes/snippets/chapter_array_and_linkedlist/list.md b/ko/codes/snippets/chapter_array_and_linkedlist/list.md index 1462ad78e..b5bd7958a 100644 --- a/ko/codes/snippets/chapter_array_and_linkedlist/list.md +++ b/ko/codes/snippets/chapter_array_and_linkedlist/list.md @@ -79,7 +79,7 @@ List nums = [1, 3, 2, 5, 4]; // 초깃값 없음 let nums1: Vec = Vec::new(); // 초깃값 지정 -let nums: Vec = vec![1, 3, 2, 5, 4]; +let mut nums: Vec = vec![1, 3, 2, 5, 4]; ``` ```c title="list.c" @@ -404,10 +404,10 @@ nums.add(5); nums.add(4); /* 중간에 원소 삽입 */ -nums.add(3, 6); // 인덱스 3에 숫자 6 삽입 +nums.add(3, 6); // 인덱스 3에 숫자 6 삽입 /* 원소 삭제 */ -nums.remove(3); // 인덱스 3의 원소 삭제 +nums.removeAt(3); // 인덱스 3의 원소 삭제 ``` ```ruby title="list.rb" diff --git a/ko/codes/snippets/chapter_backtracking/backtracking_algorithm.md b/ko/codes/snippets/chapter_backtracking/backtracking_algorithm.md index 946ccaca4..8d4acee98 100644 --- a/ko/codes/snippets/chapter_backtracking/backtracking_algorithm.md +++ b/ko/codes/snippets/chapter_backtracking/backtracking_algorithm.md @@ -1,6 +1,6 @@ ```python title="" -def backtrack(state: State, choices: list[choice], res: list[state]): +def backtrack(state: State, choices: list[Choice], res: list[State]): """백트래킹 알고리즘의 기본 틀""" # 해인지 확인 if is_solution(state): @@ -30,7 +30,7 @@ void backtrack(State *state, vector &choices, vector &res) { return; } // 모든 선택지 순회 - for (Choice choice : choices) { + for (Choice *choice : choices) { // 가지치기: 선택이 유효한지 확인 if (isValid(state, choice)) { // 시도: 선택하고 상태 갱신 @@ -189,7 +189,7 @@ function backtrack(state: State, choices: Choice[], res: State[]): void { ```dart title="" /* 백트래킹 알고리즘의 기본 틀 */ -void backtrack(State state, List, List res) { +void backtrack(State state, List choices, List res) { // 해인지 확인 if (isSolution(state)) { // 해 기록 diff --git a/ko/codes/snippets/chapter_computational_complexity/space_complexity.md b/ko/codes/snippets/chapter_computational_complexity/space_complexity.md index a6cbe347a..93212e114 100644 --- a/ko/codes/snippets/chapter_computational_complexity/space_complexity.md +++ b/ko/codes/snippets/chapter_computational_complexity/space_complexity.md @@ -196,7 +196,7 @@ function algorithm(n: number): number { // 입력 데이터 /* 클래스 */ class Node { int val; - Node next; + Node? next; Node(this.val, [this.next]); } @@ -332,8 +332,9 @@ void algorithm(int n) { void algorithm(int n) { int a = 0; // O(1) int[] b = new int[10000]; // O(1) - if (n > 10) + if (n > 10) { int[] nums = new int[n]; // O(n) + } } ``` @@ -353,7 +354,7 @@ func algorithm(n int) { b := make([]int, 10000) // O(1) var nums []int if n > 10 { - nums := make([]int, n) // O(n) + nums = make([]int, n) // O(n) } fmt.Println(a, b, nums) } @@ -413,8 +414,9 @@ fn algorithm(n: i32) { void algorithm(int n) { int a = 0; // O(1) int b[10000]; // O(1) - if (n > 10) - int nums[n] = {0}; // O(n) + if (n > 10) { + int nums[n]; // O(n) + } } ``` @@ -613,7 +615,7 @@ fn function() -> i32 { return 0; } /* 반복문의 공간 복잡도는 O(1) */ -fn loop(n: i32) { +fn for_loop(n: i32) { for i in 0..n { function(); } diff --git a/ko/codes/snippets/chapter_computational_complexity/time_complexity.md b/ko/codes/snippets/chapter_computational_complexity/time_complexity.md index 1ec2f8e2e..3cdf6d06a 100644 --- a/ko/codes/snippets/chapter_computational_complexity/time_complexity.md +++ b/ko/codes/snippets/chapter_computational_complexity/time_complexity.md @@ -774,10 +774,10 @@ def algorithm(n) a = 1 # +0(요령 1) a = a + n # +0(요령 1) # +n(요령 2) - (0...(5 * n + 1)).each do { puts 0 } + (0...(5 * n + 1)).each { puts 0 } # +n*n(요령 3) (0...(2 * n)).each do - (0...(n + 1)).each do { puts 0 } + (0...(n + 1)).each { puts 0 } end end ``` diff --git a/ko/codes/snippets/chapter_data_structure/basic_data_types.md b/ko/codes/snippets/chapter_data_structure/basic_data_types.md index c96d411db..696b131c7 100644 --- a/ko/codes/snippets/chapter_data_structure/basic_data_types.md +++ b/ko/codes/snippets/chapter_data_structure/basic_data_types.md @@ -96,7 +96,7 @@ val bools = BooleanArray(5) ```ruby title="" # Ruby의 리스트는 여러 기본 자료형과 객체 참조를 자유롭게 저장할 수 있다 -data = [0, 0.0, 'a', false, ListNode(0)] +data = [0, 0.0, 'a', false, ListNode.new(0)] ``` diff --git a/ko/codes/snippets/chapter_hashing/hash_map.md b/ko/codes/snippets/chapter_hashing/hash_map.md index e646914c5..0257348e1 100644 --- a/ko/codes/snippets/chapter_hashing/hash_map.md +++ b/ko/codes/snippets/chapter_hashing/hash_map.md @@ -184,7 +184,7 @@ map[10583] = "小鸭"; /* 조회 연산 */ // 해시 테이블에 키 key를 입력하여 값 value를 얻음 -String name = map[15937]; +String? name = map[15937]; /* 삭제 연산 */ // 해시 테이블에서 키-값 쌍 (key, value) 삭제 @@ -202,7 +202,7 @@ let mut map: HashMap = HashMap::new(); map.insert(12836, "小哈".to_string()); map.insert(15937, "小啰".to_string()); map.insert(16750, "小算".to_string()); -map.insert(13279, "小法".to_string()); +map.insert(13276, "小法".to_string()); map.insert(10583, "小鸭".to_string()); /* 조회 연산 */ diff --git a/ko/codes/snippets/chapter_heap/heap.md b/ko/codes/snippets/chapter_heap/heap.md index e5086769f..74a50ad81 100644 --- a/ko/codes/snippets/chapter_heap/heap.md +++ b/ko/codes/snippets/chapter_heap/heap.md @@ -71,7 +71,7 @@ bool isEmpty = maxHeap.empty(); /* 리스트를 입력받아 힙 구성 */ vector input{1, 3, 2, 5, 4}; -priority_queue, greater> minHeap(input.begin(), input.end()); +minHeap = priority_queue, greater>(input.begin(), input.end()); ``` ```java title="heap.java" diff --git a/ru/codes/snippets/chapter_array_and_linkedlist/linked_list.md b/ru/codes/snippets/chapter_array_and_linkedlist/linked_list.md index 5d83ddbd9..a60a52b37 100644 --- a/ru/codes/snippets/chapter_array_and_linkedlist/linked_list.md +++ b/ru/codes/snippets/chapter_array_and_linkedlist/linked_list.md @@ -28,8 +28,8 @@ class ListNode { ```csharp title="" /* Класс узла связного списка */ class ListNode(int x) { // Конструктор - int val = x; // Значение узла - ListNode? next; // Ссылка на следующий узел + public int val = x; // Значение узла + public ListNode? next; // Ссылка на следующий узел } ``` @@ -264,7 +264,7 @@ n3.next = n4; ``` ```dart title="linked_list.dart" -/* Инициализация связного списка 1 -> 3 -> 2 -> 5 -> 4 */\ +/* Инициализация связного списка 1 -> 3 -> 2 -> 5 -> 4 */ // Инициализация каждого узла ListNode n0 = ListNode(1); ListNode n1 = ListNode(3); @@ -375,9 +375,9 @@ class ListNode { ```csharp title="" /* Класс узла двусвязного списка */ class ListNode(int x) { // Конструктор - int val = x; // Значение узла - ListNode next; // Ссылка на следующий узел - ListNode prev; // Ссылка на предыдущий узел + public int val = x; // Значение узла + public ListNode? next; // Ссылка на следующий узел + public ListNode? prev; // Ссылка на предыдущий узел } ``` diff --git a/ru/codes/snippets/chapter_array_and_linkedlist/list.md b/ru/codes/snippets/chapter_array_and_linkedlist/list.md index d29dd39a5..053abf6fa 100644 --- a/ru/codes/snippets/chapter_array_and_linkedlist/list.md +++ b/ru/codes/snippets/chapter_array_and_linkedlist/list.md @@ -79,7 +79,7 @@ List nums = [1, 3, 2, 5, 4]; // Без начальных значений let nums1: Vec = Vec::new(); // С начальными значениями -let nums: Vec = vec![1, 3, 2, 5, 4]; +let mut nums: Vec = vec![1, 3, 2, 5, 4]; ``` ```c title="list.c" @@ -404,10 +404,10 @@ nums.add(5); nums.add(4); /* Вставить элемент в середину */ -nums.add(3, 6); // Вставить число 6 по индексу 3 +nums.add(3, 6); // Вставить число 6 по индексу 3 /* Удалить элемент */ -nums.remove(3); // Удалить элемент по индексу 3 +nums.removeAt(3); // Удалить элемент по индексу 3 ``` ```ruby title="list.rb" diff --git a/ru/codes/snippets/chapter_backtracking/backtracking_algorithm.md b/ru/codes/snippets/chapter_backtracking/backtracking_algorithm.md index 54727e6b5..504123302 100644 --- a/ru/codes/snippets/chapter_backtracking/backtracking_algorithm.md +++ b/ru/codes/snippets/chapter_backtracking/backtracking_algorithm.md @@ -1,6 +1,6 @@ ```python title="" -def backtrack(state: State, choices: list[choice], res: list[state]): +def backtrack(state: State, choices: list[Choice], res: list[State]): """Каркас алгоритма поиска с возвратом""" # Проверка, является ли текущее состояние решением if is_solution(state): @@ -30,7 +30,7 @@ void backtrack(State *state, vector &choices, vector &res) { return; } // Перебор всех возможных выборов - for (Choice choice : choices) { + for (Choice *choice : choices) { // Обрезка: проверка допустимости выбора if (isValid(state, choice)) { // Попытка: сделать выбор и обновить состояние @@ -189,7 +189,7 @@ function backtrack(state: State, choices: Choice[], res: State[]): void { ```dart title="" /* Каркас алгоритма поиска с возвратом */ -void backtrack(State state, List, List res) { +void backtrack(State state, List choices, List res) { // Проверка, является ли текущее состояние решением if (isSolution(state)) { // Запись решения diff --git a/ru/codes/snippets/chapter_computational_complexity/space_complexity.md b/ru/codes/snippets/chapter_computational_complexity/space_complexity.md index 62bc6df35..97cbfe543 100644 --- a/ru/codes/snippets/chapter_computational_complexity/space_complexity.md +++ b/ru/codes/snippets/chapter_computational_complexity/space_complexity.md @@ -196,7 +196,7 @@ function algorithm(n: number): number { // Входные данные /* Класс */ class Node { int val; - Node next; + Node? next; Node(this.val, [this.next]); } @@ -332,8 +332,9 @@ void algorithm(int n) { void algorithm(int n) { int a = 0; // O(1) int[] b = new int[10000]; // O(1) - if (n > 10) + if (n > 10) { int[] nums = new int[n]; // O(n) + } } ``` @@ -353,7 +354,7 @@ func algorithm(n int) { b := make([]int, 10000) // O(1) var nums []int if n > 10 { - nums := make([]int, n) // O(n) + nums = make([]int, n) // O(n) } fmt.Println(a, b, nums) } @@ -413,8 +414,9 @@ fn algorithm(n: i32) { void algorithm(int n) { int a = 0; // O(1) int b[10000]; // O(1) - if (n > 10) - int nums[n] = {0}; // O(n) + if (n > 10) { + int nums[n]; // O(n) + } } ``` @@ -613,7 +615,7 @@ fn function() -> i32 { return 0; } /* Пространственная сложность цикла равна O(1) */ -fn loop(n: i32) { +fn for_loop(n: i32) { for i in 0..n { function(); } diff --git a/ru/codes/snippets/chapter_computational_complexity/time_complexity.md b/ru/codes/snippets/chapter_computational_complexity/time_complexity.md index 3899180fe..7f2994e33 100644 --- a/ru/codes/snippets/chapter_computational_complexity/time_complexity.md +++ b/ru/codes/snippets/chapter_computational_complexity/time_complexity.md @@ -774,10 +774,10 @@ def algorithm(n) a = 1 # +0 (прием 1) a = a + n # +0 (прием 1) # +n (прием 2) - (0...(5 * n + 1)).each do { puts 0 } + (0...(5 * n + 1)).each { puts 0 } # +n*n (прием 3) (0...(2 * n)).each do - (0...(n + 1)).each do { puts 0 } + (0...(n + 1)).each { puts 0 } end end ``` diff --git a/ru/codes/snippets/chapter_data_structure/basic_data_types.md b/ru/codes/snippets/chapter_data_structure/basic_data_types.md index afac5a99e..4053a4120 100644 --- a/ru/codes/snippets/chapter_data_structure/basic_data_types.md +++ b/ru/codes/snippets/chapter_data_structure/basic_data_types.md @@ -96,7 +96,7 @@ val bools = BooleanArray(5) ```ruby title="" # Списки Ruby могут свободно хранить различные базовые типы данных и ссылки на объекты -data = [0, 0.0, 'a', false, ListNode(0)] +data = [0, 0.0, 'a', false, ListNode.new(0)] ``` diff --git a/ru/codes/snippets/chapter_hashing/hash_map.md b/ru/codes/snippets/chapter_hashing/hash_map.md index a90dbf252..80eb2476a 100644 --- a/ru/codes/snippets/chapter_hashing/hash_map.md +++ b/ru/codes/snippets/chapter_hashing/hash_map.md @@ -184,7 +184,7 @@ map[10583] = "Сяо Я"; /* Операция поиска */ // Передать в хеш-таблицу ключ key и получить значение value -String name = map[15937]; +String? name = map[15937]; /* Операция удаления */ // Удалить пару ключ-значение (key, value) из хеш-таблицы @@ -202,7 +202,7 @@ let mut map: HashMap = HashMap::new(); map.insert(12836, "Сяо Ха".to_string()); map.insert(15937, "Сяо Ло".to_string()); map.insert(16750, "Сяо Суань".to_string()); -map.insert(13279, "Сяо Фа".to_string()); +map.insert(13276, "Сяо Фа".to_string()); map.insert(10583, "Сяо Я".to_string()); /* Операция поиска */ diff --git a/ru/codes/snippets/chapter_heap/heap.md b/ru/codes/snippets/chapter_heap/heap.md index b1b88149f..37f1ae32e 100644 --- a/ru/codes/snippets/chapter_heap/heap.md +++ b/ru/codes/snippets/chapter_heap/heap.md @@ -71,7 +71,7 @@ bool isEmpty = maxHeap.empty(); /* Построение кучи из входного списка */ vector input{1, 3, 2, 5, 4}; -priority_queue, greater> minHeap(input.begin(), input.end()); +minHeap = priority_queue, greater>(input.begin(), input.end()); ``` ```java title="heap.java" diff --git a/zh-hant/codes/snippets/chapter_array_and_linkedlist/linked_list.md b/zh-hant/codes/snippets/chapter_array_and_linkedlist/linked_list.md index 1939b0fa3..d82aada57 100644 --- a/zh-hant/codes/snippets/chapter_array_and_linkedlist/linked_list.md +++ b/zh-hant/codes/snippets/chapter_array_and_linkedlist/linked_list.md @@ -28,8 +28,8 @@ class ListNode { ```csharp title="" /* 鏈結串列節點類別 */ class ListNode(int x) { //建構子 - int val = x; // 節點值 - ListNode? next; // 指向下一節點的引用 + public int val = x; // 節點值 + public ListNode? next; // 指向下一節點的引用 } ``` @@ -264,7 +264,7 @@ n3.next = n4; ``` ```dart title="linked_list.dart" -/* 初始化鏈結串列 1 -> 3 -> 2 -> 5 -> 4 */\ +/* 初始化鏈結串列 1 -> 3 -> 2 -> 5 -> 4 */ // 初始化各個節點 ListNode n0 = ListNode(1); ListNode n1 = ListNode(3); @@ -375,9 +375,9 @@ class ListNode { ```csharp title="" /* 雙向鏈結串列節點類別 */ class ListNode(int x) { // 建構子 - int val = x; // 節點值 - ListNode next; // 指向後繼節點的引用 - ListNode prev; // 指向前驅節點的引用 + public int val = x; // 節點值 + public ListNode? next; // 指向後繼節點的引用 + public ListNode? prev; // 指向前驅節點的引用 } ``` diff --git a/zh-hant/codes/snippets/chapter_array_and_linkedlist/list.md b/zh-hant/codes/snippets/chapter_array_and_linkedlist/list.md index aacf2931d..4335b5b0c 100644 --- a/zh-hant/codes/snippets/chapter_array_and_linkedlist/list.md +++ b/zh-hant/codes/snippets/chapter_array_and_linkedlist/list.md @@ -79,7 +79,7 @@ List nums = [1, 3, 2, 5, 4]; // 無初始值 let nums1: Vec = Vec::new(); // 有初始值 -let nums: Vec = vec![1, 3, 2, 5, 4]; +let mut nums: Vec = vec![1, 3, 2, 5, 4]; ``` ```c title="list.c" @@ -404,10 +404,10 @@ nums.add(5); nums.add(4); /* 在中間插入元素 */ -nums.add(3, 6); // 在索引 3 處插入數字 6 +nums.add(3, 6); // 在索引 3 處插入數字 6 /* 刪除元素 */ -nums.remove(3); // 刪除索引 3 處的元素 +nums.removeAt(3); // 刪除索引 3 處的元素 ``` ```ruby title="list.rb" diff --git a/zh-hant/codes/snippets/chapter_backtracking/backtracking_algorithm.md b/zh-hant/codes/snippets/chapter_backtracking/backtracking_algorithm.md index 4c9832a21..6cc308dac 100644 --- a/zh-hant/codes/snippets/chapter_backtracking/backtracking_algorithm.md +++ b/zh-hant/codes/snippets/chapter_backtracking/backtracking_algorithm.md @@ -1,6 +1,6 @@ ```python title="" -def backtrack(state: State, choices: list[choice], res: list[state]): +def backtrack(state: State, choices: list[Choice], res: list[State]): """回溯演算法框架""" # 判斷是否為解 if is_solution(state): @@ -30,7 +30,7 @@ void backtrack(State *state, vector &choices, vector &res) { return; } // 走訪所有選擇 - for (Choice choice : choices) { + for (Choice *choice : choices) { // 剪枝:判斷選擇是否合法 if (isValid(state, choice)) { // 嘗試:做出選擇,更新狀態 @@ -189,7 +189,7 @@ function backtrack(state: State, choices: Choice[], res: State[]): void { ```dart title="" /* 回溯演算法框架 */ -void backtrack(State state, List, List res) { +void backtrack(State state, List choices, List res) { // 判斷是否為解 if (isSolution(state)) { // 記錄解 diff --git a/zh-hant/codes/snippets/chapter_computational_complexity/space_complexity.md b/zh-hant/codes/snippets/chapter_computational_complexity/space_complexity.md index 77d41635b..ae75c59d7 100644 --- a/zh-hant/codes/snippets/chapter_computational_complexity/space_complexity.md +++ b/zh-hant/codes/snippets/chapter_computational_complexity/space_complexity.md @@ -196,7 +196,7 @@ function algorithm(n: number): number { // 輸入資料 /* 類別 */ class Node { int val; - Node next; + Node? next; Node(this.val, [this.next]); } @@ -332,8 +332,9 @@ void algorithm(int n) { void algorithm(int n) { int a = 0; // O(1) int[] b = new int[10000]; // O(1) - if (n > 10) + if (n > 10) { int[] nums = new int[n]; // O(n) + } } ``` @@ -353,7 +354,7 @@ func algorithm(n int) { b := make([]int, 10000) // O(1) var nums []int if n > 10 { - nums := make([]int, n) // O(n) + nums = make([]int, n) // O(n) } fmt.Println(a, b, nums) } @@ -413,8 +414,9 @@ fn algorithm(n: i32) { void algorithm(int n) { int a = 0; // O(1) int b[10000]; // O(1) - if (n > 10) - int nums[n] = {0}; // O(n) + if (n > 10) { + int nums[n]; // O(n) + } } ``` @@ -613,7 +615,7 @@ fn function() -> i32 { return 0; } /* 迴圈的空間複雜度為 O(1) */ -fn loop(n: i32) { +fn for_loop(n: i32) { for i in 0..n { function(); } diff --git a/zh-hant/codes/snippets/chapter_computational_complexity/time_complexity.md b/zh-hant/codes/snippets/chapter_computational_complexity/time_complexity.md index 5c83a8353..ee6c09e51 100644 --- a/zh-hant/codes/snippets/chapter_computational_complexity/time_complexity.md +++ b/zh-hant/codes/snippets/chapter_computational_complexity/time_complexity.md @@ -774,10 +774,10 @@ def algorithm(n) a = 1 # +0(技巧 1) a = a + n # +0(技巧 1) # +n(技巧 2) - (0...(5 * n + 1)).each do { puts 0 } + (0...(5 * n + 1)).each { puts 0 } # +n*n(技巧 3) (0...(2 * n)).each do - (0...(n + 1)).each do { puts 0 } + (0...(n + 1)).each { puts 0 } end end ``` diff --git a/zh-hant/codes/snippets/chapter_data_structure/basic_data_types.md b/zh-hant/codes/snippets/chapter_data_structure/basic_data_types.md index c4f2447ea..4acbfe893 100644 --- a/zh-hant/codes/snippets/chapter_data_structure/basic_data_types.md +++ b/zh-hant/codes/snippets/chapter_data_structure/basic_data_types.md @@ -96,7 +96,7 @@ val bools = BooleanArray(5) ```ruby title="" # Ruby 的串列可以自由儲存各種基本資料型別和物件引用 -data = [0, 0.0, 'a', false, ListNode(0)] +data = [0, 0.0, 'a', false, ListNode.new(0)] ``` diff --git a/zh-hant/codes/snippets/chapter_hashing/hash_map.md b/zh-hant/codes/snippets/chapter_hashing/hash_map.md index e7dee5629..205410178 100644 --- a/zh-hant/codes/snippets/chapter_hashing/hash_map.md +++ b/zh-hant/codes/snippets/chapter_hashing/hash_map.md @@ -184,7 +184,7 @@ map[10583] = "小鴨"; /* 查詢操作 */ // 向雜湊表中輸入鍵 key ,得到值 value -String name = map[15937]; +String? name = map[15937]; /* 刪除操作 */ // 在雜湊表中刪除鍵值對 (key, value) @@ -202,7 +202,7 @@ let mut map: HashMap = HashMap::new(); map.insert(12836, "小哈".to_string()); map.insert(15937, "小囉".to_string()); map.insert(16750, "小算".to_string()); -map.insert(13279, "小法".to_string()); +map.insert(13276, "小法".to_string()); map.insert(10583, "小鴨".to_string()); /* 查詢操作 */ diff --git a/zh-hant/codes/snippets/chapter_heap/heap.md b/zh-hant/codes/snippets/chapter_heap/heap.md index 96bfd66f1..c62de7af2 100644 --- a/zh-hant/codes/snippets/chapter_heap/heap.md +++ b/zh-hant/codes/snippets/chapter_heap/heap.md @@ -71,7 +71,7 @@ bool isEmpty = maxHeap.empty(); /* 輸入串列並建堆積 */ vector input{1, 3, 2, 5, 4}; -priority_queue, greater> minHeap(input.begin(), input.end()); +minHeap = priority_queue, greater>(input.begin(), input.end()); ``` ```java title="heap.java"