@@ -0,0 +1,876 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0Apublic class Task295 %7B%0A%0A%0A    private final List%3CInteger%3E numbers = new ArrayList%3C%3E();%0A%0A    public void addNum(int num) %7B%0A        int i = Collections.binarySearch(numbers, num);%0A        numbers.add(i %3E= 0 ? i : -i - 1, num);%0A    %7D%0A%0A    public double findMedian() %7B%0A        if (numbers.size() %25 2 == 0) %7B%0A            return ((double) numbers.get(numbers.size() / 2 - 1) + numbers.get(numbers.size() / 2)) / 2;%0A        %7D else %7B%0A            return numbers.get(numbers.size() / 2);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Task295 task295 = new Task295();%0A        task295.addNum(6);%0A        task295.addNum(10);%0A        task295.addNum(2);%0A        task295.addNum(6);%0A        task295.addNum(5);%0A%0A        System.out.println(task295.findMedian());%0A    %7D%0A%7D%0A

Add Task295