public void Test1() { Tuple <int, int>[] ranges = new Tuple <int, int>[] { new Tuple <int, int>(2, 8), new Tuple <int, int>(5, 10), new Tuple <int, int>(7, 20) }; KthElementNLogN nlogn = new KthElementNLogN() { Ranges = ranges }; KthElementN n = new KthElementN() { Ranges = ranges }; this.Compare(2, 1, nlogn, n); this.Compare(5, 4, nlogn, n); this.Compare(5, 5, nlogn, n); this.Compare(7, 10, nlogn, n); }
private void Compare(int expected, int value, KthElementNLogN nlogn, KthElementN n) { Assert.AreEqual(expected, nlogn.Solve(value)); Assert.AreEqual(expected, n.Solve(value)); }