mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
1. Remove unused libs.
2. Add file headers. 3. Modify file name to match Java's. 4. Fix some issues.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace hello_algo.include
|
||||
public class ListNode
|
||||
{
|
||||
public int val;
|
||||
public ListNode next;
|
||||
public ListNode? next;
|
||||
|
||||
/// <summary>
|
||||
/// Generate a linked list with an array
|
||||
@@ -26,7 +26,7 @@ namespace hello_algo.include
|
||||
/// </summary>
|
||||
/// <param name="arr"></param>
|
||||
/// <returns></returns>
|
||||
public static ListNode ArrToLinkedList(int[] arr)
|
||||
public static ListNode? ArrToLinkedList(int[] arr)
|
||||
{
|
||||
ListNode dum = new ListNode(0);
|
||||
ListNode head = dum;
|
||||
@@ -44,7 +44,7 @@ namespace hello_algo.include
|
||||
/// <param name="head"></param>
|
||||
/// <param name="val"></param>
|
||||
/// <returns></returns>
|
||||
public static ListNode GetListNode(ListNode head, int val)
|
||||
public static ListNode? GetListNode(ListNode? head, int val)
|
||||
{
|
||||
while (head != null && head.val != val)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.SymbolStore;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
// File: ListNode.cs
|
||||
// Created Time: 2022-12-16
|
||||
// Author: mingXta (1195669834@qq.com)
|
||||
|
||||
namespace hello_algo.include
|
||||
{
|
||||
@@ -21,21 +18,6 @@ namespace hello_algo.include
|
||||
|
||||
public class PrintUtil
|
||||
{
|
||||
/**
|
||||
* Print a linked list
|
||||
* @param head
|
||||
*/
|
||||
public static void printLinkedList(ListNode head)
|
||||
{
|
||||
List<String> list = new();
|
||||
while (head != null)
|
||||
{
|
||||
list.Add(head.val.ToString());
|
||||
head = head.next;
|
||||
}
|
||||
Console.Write(String.Join(" -> ", list));
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface of the tree printer
|
||||
* This tree printer is borrowed from TECHIE DELIGHT
|
||||
@@ -81,7 +63,7 @@ namespace hello_algo.include
|
||||
}
|
||||
|
||||
showTrunks(trunk);
|
||||
Console.Write(" " + root.val);
|
||||
Console.WriteLine(" " + root.val);
|
||||
|
||||
if (prev != null)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
// File: ListNode.cs
|
||||
// Created Time: 2022-12-16
|
||||
// Author: mingXta (1195669834@qq.com)
|
||||
|
||||
namespace hello_algo.include
|
||||
{
|
||||
public class TreeNode
|
||||
{
|
||||
public int? val; // 结点值
|
||||
public int height; // 结点高度
|
||||
public int height; // 结点高度
|
||||
public TreeNode? left; // 左子结点引用
|
||||
public TreeNode? right; // 右子结点引用
|
||||
|
||||
|
||||
Reference in New Issue
Block a user