Skip to content

Commit 1614051

Browse files
committed
test(dp): by and sell stock
1 parent 9cb1302 commit 1614051

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

algorithms/dynamic_programming/buy_sell_stock/test_max_profit.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,34 @@ def test_prices_7_6_4_3_1_should_return_0(self):
6666
actual = max_profit_two_pointers(nums)
6767
self.assertEqual(expected, actual)
6868

69+
def test_6(self):
70+
"""310, 315, 275, 295, 260, 270, 290, 230, 255, 250 should return 30"""
71+
nums = [310, 315, 275, 295, 260, 270, 290, 230, 255, 250]
72+
expected = 30
73+
actual = max_profit_two_pointers(nums)
74+
self.assertEqual(expected, actual)
75+
76+
def test_7(self):
77+
"""100, 180, 260, 310, 40, 535, 695 should return 655"""
78+
nums = [100, 180, 260, 310, 40, 535, 695]
79+
expected = 655
80+
actual = max_profit_two_pointers(nums)
81+
self.assertEqual(expected, actual)
82+
83+
def test_8(self):
84+
"""50, 40, 30, 20, 10 should return 0"""
85+
nums = [50, 40, 30, 20, 10]
86+
expected = 0
87+
actual = max_profit_two_pointers(nums)
88+
self.assertEqual(expected, actual)
89+
90+
def test_9(self):
91+
"""110, 215, 180, 335, 5 should return 225"""
92+
nums = [110, 215, 180, 335, 5]
93+
expected = 225
94+
actual = max_profit_two_pointers(nums)
95+
self.assertEqual(expected, actual)
96+
6997

7098
if __name__ == "__main__":
7199
unittest.main()

0 commit comments

Comments
 (0)