public void FourByThree() { var input = new int[, ] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; var expected = new int[] { 1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7 }; var result = LeetCodeSolutions.SpiralOrder(input).ToArray(); Console.WriteLine("Expected:"); foreach (var num in expected) { Console.Write($"{num} "); } Console.WriteLine(); Console.WriteLine("Result:"); foreach (var num in result) { Console.Write($"{num} "); } Assert.IsTrue(expected.SequenceEqual(result)); }
public void OneTwoThreeFour() { var input = new int[, ] { { 1, 2 }, { 3, 4 } }; var expected = new int[] { 1, 2, 4, 3 }; var result = LeetCodeSolutions.SpiralOrder(input).ToArray(); Console.WriteLine("Expected:"); foreach (var num in expected) { Console.Write($"{num} "); } Console.WriteLine(); Console.WriteLine("Result:"); foreach (var num in result) { Console.Write($"{num} "); } Assert.IsTrue(expected.SequenceEqual(result)); }
public void ThreeByThree() { var input = new int[, ] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; var expected = new int[] { 1, 2, 3, 6, 9, 8, 7, 4, 5 }; var result = LeetCodeSolutions.SpiralOrder(input).ToArray(); Console.WriteLine("Expected:"); foreach (var num in expected) { Console.Write($"{num} "); } Console.WriteLine(); Console.WriteLine("Result:"); foreach (var num in result) { Console.Write($"{num} "); } Assert.IsTrue(expected.SequenceEqual(result)); }
public void ResultIsZeroAndOne() { var leet = new LeetCodeSolutions(); var nums = new[] { 2, 7, 11, 15 }; var result = leet.TwoSum(nums, 9); Assert.IsTrue(result[0] == 0 && result[1] == 1); }
public void ResultExists() { var leet = new LeetCodeSolutions(); var nums = new[] { 230, 863, 916, 585, 981, 404, 316, 785, 88, 12, 70, 435, 384, 778, 887, 755, 740, 337, 86, 92, 325, 422, 815, 650, 920, 125, 277, 336, 221, 847, 168, 23, 677, 61, 400, 136, 874, 363, 394, 199, 863, 997, 794, 587, 124, 321, 212, 957, 764, 173, 314, 422, 927, 783, 930, 282, 306, 506, 44, 926, 691, 568, 68, 730, 933, 737, 531, 180, 414, 751, 28, 546, 60, 371, 493, 370, 527, 387, 43, 541, 13, 457, 328, 227, 652, 365, 430, 803, 59, 858, 538, 427, 583, 368, 375, 173, 809, 896, 370, 789 }; var result = leet.TwoSum(nums, 542); Assert.IsTrue(result != null); }