Esempio n. 1
0
        public void BestTimeToBuyAndSellStockTestMethod()
        {
            var bestTimeToBuyAndSellStock = new BestTimeToBuyAndSellStock();
            var input1    = new int[] { 7, 1, 5, 3, 6, 4 };
            var expected1 = 5;
            var actual1   = bestTimeToBuyAndSellStock.MaxProfit(input1);

            Assert.AreEqual(expected1, actual1);

            var input2    = new int[] { 7, 6, 4, 3, 1 };
            var expected2 = 0;
            var actual2   = bestTimeToBuyAndSellStock.MaxProfit(input2);

            Assert.AreEqual(expected2, actual2);

            var input3    = new int[] {};
            var expected3 = 0;
            var actual3   = bestTimeToBuyAndSellStock.MaxProfit(input3);

            Assert.AreEqual(expected3, actual3);
        }
Esempio n. 2
0
 public static void MainMethod()
 {
     int[] prices = new int[] { 0, 0, 1, 1, 1, 2, 2, 3, 3, 4 };
     BestTimeToBuyAndSellStock obj = new BestTimeToBuyAndSellStock();
     int x = obj.MaxProfit(prices);
 }