Skip to content

Instantly share code, notes, and snippets.

View uthrakrishnan's full-sized avatar

Uthra Krishnan uthrakrishnan

View GitHub Profile
Function.prototype.myBind = function (newThis, ...args1) {
var fn = this;
return function (...args2) {
return fn.apply(newThis, args1.concat(args2));
};
}
var math = {
add: function(a, b) { return a + b}
}
Given an arrayOfInts, find the highestProduct you can get from three of the integers.
The input arrayOfInts will always have at least three integers.
Gotchas
Does your function work with negative numbers? If arrayOfInts is [−10,−10,1,3,2][-10, -10, 1, 3, 2][−10,−10,1,3,2] we should return 300300300 (which we get by taking −10∗−10∗3-10 * -10 * 3−10∗−10∗3).
We can do this in O(n)O(n)O(n) time and O(1)O(1)O(1) space.