Exemple #1
0
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))
Exemple #2
0
def main():
   mf = MedianFinder()
   for line in stdin:
      mf.addNum(int(line))
      print mf.findMedian()
Exemple #3
0
#!/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())