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 productArrayValues(arr1, arr2) { | |
return quickSort(arr1, 0, arr1.length - 1)[arr1.length - 1] * quickSort(arr2, 0, arr2.length - 1)[0]; | |
} | |
function quickSort(arr, left, right) { | |
if (arr.length < 2) return arr; | |
var pivot, partitionIndex; | |
if (left < right) { |
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
// First Solution | |
function duplicate(arr, num) { | |
var newArr = []; | |
for (var i = 1; i <= num; i++) { | |
newArr = newArr.concat(arr); | |
} | |
return newArr; | |
} |
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 seatsInTheater(numCols, numRows, myCol, myRow) { | |
var calcCols = myCol > numCols / 2 ? numCols - myCol + 1 : myCol, | |
unblocked = ((numCols - calcCols) * numRows) + ((myRow - 1) * calcCols); | |
return numCols * numRows - unblocked - 1; | |
} | |
seatsInTheater(16, 11, 5, 3); |
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 PleaseDontGo = (function() { | |
var s; | |
return { | |
settings: { | |
originalTitle: document.title, | |
// New title when tab is changed | |
newTitle: 'Please Don\'t Go', | |
favicon: document.querySelectorAll('[rel="icon"]')[0], | |
originalFavicon: document.querySelectorAll('[rel="icon"]')[0].href, |
NewerOlder