mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
feat(csharp): add csharp code for array binary tree (#632)
This commit is contained in:
@ -16,12 +16,16 @@ public class Trunk {
|
||||
}
|
||||
};
|
||||
|
||||
public class PrintUtil {
|
||||
public static class PrintUtil {
|
||||
/* Print a list */
|
||||
public static void PrintList<T>(IList<T> list) {
|
||||
Console.WriteLine("[" + string.Join(", ", list) + "]");
|
||||
}
|
||||
|
||||
public static string PrintList<T>(this IEnumerable<T?> list) {
|
||||
return $"[ {string.Join(", ", list.Select(x => x?.ToString() ?? "null"))} ]";
|
||||
}
|
||||
|
||||
/* Print a matrix (Array) */
|
||||
public static void PrintMatrix<T>(T[][] matrix) {
|
||||
Console.WriteLine("[");
|
||||
@ -131,4 +135,4 @@ public class PrintUtil {
|
||||
TreeNode tree = TreeNode.ListToTree(list.Cast<int?>().ToList());
|
||||
PrintTree(tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user