def test_1(): mf = MedianFinder() arr = [] for _ in xrange(100): x = np.random.randint(-100, 100) mf.addNum(x) arr.append(x) assert mf.findMedian() == np.median(np.array(arr))
def main(): mf = MedianFinder() for line in stdin: mf.addNum(int(line)) print mf.findMedian()
#!/usr/bin/env python # -*- coding: utf-8 -*- from solution import MedianFinder mf = MedianFinder() mf.addNum(1) mf.addNum(2) print(mf.findMedian()) mf.addNum(3) print(mf.findMedian())