public void ReverseKGroupTest_EmptyList() { var solution = new _025_ReverseNodesInKGroup(); var result = solution.ReverseKGroup(null, 2); Assert.IsNull(result); }
public void ReverseKGroupTest_KLargerThanLenght() { var input = TestHelper.GenerateList(new int[] { 1, 2, 3, 4, 5 }); var solution = new _025_ReverseNodesInKGroup(); var result = solution.ReverseKGroup(input, 6); AssertHelper.AssertLinkList(new int[] { 1, 2, 3, 4, 5 }, result); }
public void ReverseKGroupTest() { var input = TestHelper.GenerateList(new int[] { 1, 2, 3, 4, 5 }); var solution = new _025_ReverseNodesInKGroup(); var result = solution.ReverseKGroup(input, 2); AssertHelper.AssertLinkList(new int[] { 2, 1, 4, 3, 5 }, result); input = TestHelper.GenerateList(new int[] { 1, 2, 3, 4, 5 }); result = solution.ReverseKGroup(input, 3); AssertHelper.AssertLinkList(new int[] { 3, 2, 1, 4, 5 }, result); }