This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = [-2, 1, -3, 4, -1, 2, 1, -5, 4]; | |
// Maximum Subarray | |
function maxiumumSubArray (inputArray) { | |
var reduced; | |
var max = 0; | |
for (var i = 0; i < input.length; i++) { | |
for (var j = i + 1; j < input.length; j++) { | |
reduced = input.slice(i, j).reduce(function(a, b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertObjectKeyToArray(obj,key) { | |
if( obj.hasOwnProperty(key) ) { | |
if( Object.prototype.toString.call(obj[key]) === '[object Object]' ) { | |
new_array = []; | |
for ( objkey in obj[key] ) { | |
new_array.push(obj[key][objkey]); | |
} | |
obj[key] = new_array; | |
} else { | |
print("{" + obj._id + "} has type " + typeof obj[key]+ " for key: " + key ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawChart() { | |
var options = { | |
chart: { | |
renderTo: 'chart', | |
}, | |
series: [] | |
}; | |
$.getJSON('path/to/data', function(data) { | |
options.series = data.series; | |
options.xAxis.categories = data.categories; |