javascript, o(n) addNum, o(1) findMedian. clean w/ comments
\nclass MedianFinder {\n    constructor() {\n        // set up array\n        this.arr = [];\n    }\n\t\n    /**\n     * @param {number} num\n     * @return {vo
```\nclass MedianFinder {\n    constructor() {\n        // set up array\n        this.arr = [];\n    }\n\t\n    /**\n     * @param {number} num\n     * @return {void}\n     */\n    addNum(num) {\n        // check if array is size 0, just push\n        if (this.arr.length === 0) {\n            this.arr.push(num);\n            return;\n        }\n\t\t\n        // left and right pointers for binary search\n        let l = 0;\n        let r = this.arr.length;\n\t\t\n        // keep going until pointers meet\n        while (l < r) {\n            // get mid point\n            const mid = Math.floor((l + r) / 2);\n            // check if we can insert at mid\n            if (num > this.arr[mid]) {\n                // search right half of array\n                l = mid + 1;\n            } else {\n                // search left half of array\n                r = mid;\n            }\n        }\n\t\t\n        // we can insert at left pointer\n        this.arr.splice(l, 0, num);\n    }\n\t\n    /**\n     * @return {number}\n     */\n    findMedian() {\n        // if odd, return middle, if even, return avg of two middle\n        const mid = Math.floor(this.arr.length / 2);\n        return (this.arr.length & 1) === 1\n            ? this.arr[mid]\n            : (this.arr[mid] + this.arr[mid - 1]) / 2;\n    }\n}\n```\n
['Binary Search', 'JavaScript']