/// <summary>
/// 单向列表
/// </summary>
public class LinkedList {
public string val;
public LinkedList next;
public LinkedList(string val,LinkedList next)
{
this.val = val;
this.next = next;
}
}
/// <summary>
///
/// </summary>
public static class LinkedListEx
{
/// <summary>
/// 获取长度
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public static int GetLength(this LinkedList list)
{
int length = 0;
if (list is null)
{
return length;
}
LinkedList pointer = list;
while (pointer.next != null)
{
length ++;
pointer = pointer.next;
}
return length;
}
}
/// <summary>
///
/// </summary>
public string FindTheMergedNode(LinkedList list1, LinkedList list2)
{
// todo
}
评论