|
1 | | -from algorithms.arrays import delete_nth, delete_nth_naive |
2 | | -from algorithms.arrays import flatten, flatten_iter |
3 | | -from algorithms.arrays import garage |
4 | | -from algorithms.arrays import josephus |
5 | | -from algorithms.arrays import longest_non_repeat_v1, longest_non_repeat_v2 |
6 | | -from algorithms.arrays import Interval, merge_intervals |
7 | | -from algorithms.arrays import missing_ranges |
8 | | -from algorithms.arrays import move_zeros |
9 | | -from algorithms.arrays import plus_one_v1, plus_one_v2, plus_one_v3 |
10 | | -from algorithms.arrays import rotate_v1, rotate_v2, rotate_v3 |
11 | | -from algorithms.arrays import summarize_ranges |
12 | | -from algorithms.arrays import three_sum |
13 | | -from algorithms.arrays import two_sum |
| 1 | +from algorithms.arrays import ( |
| 2 | + delete_nth, delete_nth_naive, |
| 3 | + flatten_iter, flatten, |
| 4 | + garage, |
| 5 | + josephus, |
| 6 | + longest_non_repeat_v1, longest_non_repeat_v2, |
| 7 | + Interval, merge_intervals, |
| 8 | + missing_ranges, |
| 9 | + move_zeros, |
| 10 | + plus_one_v1, plus_one_v2, plus_one_v3, |
| 11 | + rotate_v1, rotate_v2, rotate_v3, |
| 12 | + summarize_ranges, |
| 13 | + three_sum, |
| 14 | + two_sum, |
| 15 | + max_ones_index |
| 16 | +) |
14 | 17 |
|
15 | 18 | import unittest |
16 | 19 |
|
@@ -152,6 +155,15 @@ def test_longest_non_repeat_v2(self): |
152 | 155 | self.assertEqual(longest_non_repeat_v2(string), 3) |
153 | 156 |
|
154 | 157 |
|
| 158 | +class TestMaxOnesIndex(unittest.TestCase): |
| 159 | + |
| 160 | + def test_max_ones_index(self): |
| 161 | + |
| 162 | + self.assertEqual(9, max_ones_index([1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1])) |
| 163 | + self.assertEqual(3, max_ones_index([1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1])) |
| 164 | + self.assertEqual(-1, max_ones_index([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) |
| 165 | + |
| 166 | + |
155 | 167 | class TestMergeInterval(unittest.TestCase): |
156 | 168 |
|
157 | 169 | def test_merge(self): |
|
0 commit comments