public void InsertBetween3() { var sol = new InsertInterval(); var output = sol.Insert(new[] { new[] { 2, 3 }, new[] { 6, 9 } }, new[] { 10, 11 }); var expected = new[] { new [] { 2, 3 }, new [] { 6, 9 }, new [] { 10, 11 }, }; Assert.AreEqual(expected.Length, output.Length); for (int i = 0; i < output.Length; i++) { CollectionAssert.AreEqual(expected[i], output[i]); } }
public void TestInsertNewInterval() { var insertIntervalSolver = new InsertInterval(); var intervals = new List <Tuple <int, int> > { Tuple.Create(1, 3), Tuple.Create(6, 9) }; var interval = Tuple.Create(2, 5); var result = insertIntervalSolver.InsertNewInterval(intervals, interval); intervals = new List <Tuple <int, int> > { Tuple.Create(1, 2), Tuple.Create(3, 5), Tuple.Create(6, 7), Tuple.Create(8, 10), Tuple.Create(12, 16) }; interval = Tuple.Create(4, 8); result = insertIntervalSolver.InsertNewInterval(intervals, interval); intervals = new List <Tuple <int, int> > { }; interval = Tuple.Create(5, 7); result = insertIntervalSolver.InsertNewInterval(intervals, interval); intervals = new List <Tuple <int, int> > { Tuple.Create(1, 5) }; interval = Tuple.Create(2, 3); result = insertIntervalSolver.InsertNewInterval(intervals, interval); intervals = new List <Tuple <int, int> > { Tuple.Create(1, 5) }; interval = Tuple.Create(2, 7); result = insertIntervalSolver.InsertNewInterval(intervals, interval); }
public void Example3() { var sol = new InsertInterval(); var output = sol.Insert(new[] { new[] { 1, 2 }, new[] { 3, 5 }, new[] { 6, 7 }, new[] { 8, 10 }, new[] { 12, 16 } }, new[] { 0, 11 }); var expected = new[] { new [] { 0, 11 }, new [] { 12, 16 } }; Assert.AreEqual(expected.Length, output.Length); for (int i = 0; i < output.Length; i++) { CollectionAssert.AreEqual(expected[i], output[i]); } }
public void Given_intervals_When_insert_Then_return() { var intervals = new List <Interval> { new Interval(1, 2), new Interval(3, 5), new Interval(6, 7), new Interval(8, 10), new Interval(12, 16), }; var result = InsertInterval.Insert(intervals, new Interval(4, 9)); Assert.AreEqual(3, result.Count); }
public void Example1() { var sol = new InsertInterval(); var output = sol.Insert(new[] { new[] { 1, 3 }, new[] { 6, 9 } }, new[] { 2, 5 }); var expected = new[] { new [] { 1, 5 }, new [] { 6, 9 } }; Assert.AreEqual(expected.Length, output.Length); for (int i = 0; i < output.Length; i++) { CollectionAssert.AreEqual(expected[i], output[i]); } }