Javascript solution
var minPatches = function(nums, n) {\n        var covered=1,count=0,i=0;\n        //current covered range is [1,covered)\n        while(covered<=n){\n          
    var minPatches = function(nums, n) {\n        var covered=1,count=0,i=0;\n        //current covered range is [1,covered)\n        while(covered<=n){\n            if(i>=nums.length||covered<nums[i]){\n                count++;\n                covered+=covered;\n            }else covered+=nums[i++];\n        }\n        return count;\n    };
['JavaScript']