Javascript solution using binary search
```\nvar MedianFinder = function() {\n    this.ary = [];\n};\n\n/ \n * @param {number} num\n * @return {void}\n */\nMedianFinder.prototype.addNum = function(num
```\nvar MedianFinder = function() {\n    this.ary = [];\n};\n\n/** \n * @param {number} num\n * @return {void}\n */\nMedianFinder.prototype.addNum = function(num) {\n   \n    var low = 0 ; \n    var high = this.ary.length-1;\n    \n    while(low <= high)\n        {\n            var mid = Math.floor((high + low)/2);\n            \n            if(this.ary[mid]  < num)\n                {\n                    low = mid+1;\n                }\n            else\n                {\n                    high =mid-1;\n                }\n        }\n    \n    // insert at  location trick for javascript array.\n    this.ary.splice(low, 0, num);\n    \n};\n\n/**\n * @return {number}\n */\nMedianFinder.prototype.findMedian = function() {\n    \n    if(this.ary.length % 2 ==0)\n        {\n            var mid = this.ary.length/2;\n            return (this.ary[mid] + this.ary[mid-1])/2;\n        }\n    else\n        {\n            var mid = Math.floor(this.ary.length/2);\n            return (this.ary[mid]);\n        }\n    \n};\n
[]