Format C, C++, C#, Go, Java, Python, Rust code.

This commit is contained in:
krahets
2023-09-02 23:54:38 +08:00
parent b6ac6aa7d7
commit dd72335235
53 changed files with 152 additions and 154 deletions

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_backtracking;
namespace hello_algo.chapter_backtracking;
public class subset_sum_i {
/* 回溯算法:子集和 I */

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_backtracking;
namespace hello_algo.chapter_backtracking;
public class subset_sum_i_naive {
/* 回溯算法:子集和 I */

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_backtracking;
namespace hello_algo.chapter_backtracking;
public class subset_sum_ii {
/* 回溯算法:子集和 II */

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_dynamic_programming;
namespace hello_algo.chapter_dynamic_programming;
public class climbing_stairs_backtrack {
/* 回溯 */

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_dynamic_programming;
namespace hello_algo.chapter_dynamic_programming;
public class climbing_stairs_dfs {
/* 搜索 */

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_dynamic_programming;
namespace hello_algo.chapter_dynamic_programming;
public class climbing_stairs_dp {
/* 爬楼梯:动态规划 */

View File

@@ -4,13 +4,13 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_dynamic_programming;
namespace hello_algo.chapter_dynamic_programming;
public class min_path_sum {
/* 最小路径和:暴力搜索 */
public int minPathSumDFS(int[][] grid, int i, int j) {
// 若为左上角单元格,则终止搜索
if (i == 0 && j == 0){
if (i == 0 && j == 0) {
return grid[0][0];
}
// 若行列索引越界,则返回 +∞ 代价

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_hashing;
namespace hello_algo.chapter_hashing;
public class built_in_hash {
[Test]

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_hashing;
namespace hello_algo.chapter_hashing;
public class simple_hash {
/* 加法哈希 */

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_heap;
namespace hello_algo.chapter_heap;
public class top_k {
/* 基于堆查找数组中最大的 k 个元素 */

View File

@@ -18,7 +18,7 @@ public class bucket_sort {
// 1. 将数组元素分配到各个桶中
foreach (float num in nums) {
// 输入数据范围 [0, 1),使用 num * k 映射到索引范围 [0, k-1]
int i = (int) (num * k);
int i = (int)(num * k);
// 将 num 添加进桶 i
buckets[i].Add(num);
}

View File

@@ -4,7 +4,7 @@
* Author: hpstory (hpstory1024@163.com)
*/
namespace hello_algo.chapter_sorting;
namespace hello_algo.chapter_sorting;
public class heap_sort {
/* 堆的长度为 n ,从节点 i 开始,从顶至底堆化 */

View File

@@ -36,7 +36,7 @@ public class TreeNode {
/* 将列表反序列化为二叉树:递归 */
private static TreeNode? ListToTreeDFS(List<int?> arr, int i) {
if (i < 0|| i >= arr.Count || !arr[i].HasValue) {
if (i < 0 || i >= arr.Count || !arr[i].HasValue) {
return null;
}
TreeNode root = new TreeNode(arr[i].Value);