public void TwoToLast_EmptyList_error() { SingleLinkedList <int> list = new SingleLinkedList <int>(); Assert.Throws <IndexOutOfRangeException>( () => list.KthToLast(2) ); }
public void FiveToLast_EmptyList_error() { SingleLinkedList <int> list = new SingleLinkedList <int>(); list.InsertAtEnd(7); list.InsertAtEnd(1); list.InsertAtEnd(5); list.InsertAtEnd(4); Assert.Throws <IndexOutOfRangeException>( () => list.KthToLast(5) ); }
public void KToLast_7154_Expected(int k, int expect) { SingleLinkedList <int> list = new SingleLinkedList <int>(); list.InsertAtEnd(7); list.InsertAtEnd(1); list.InsertAtEnd(5); list.InsertAtEnd(4); int kth = list.KthToLast(k); Assert.AreEqual(expect, kth); }