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
// Problem 1: | |
// There is a matrix of cells like a spreadsheet - let's call the JavaScript 2-dimensional array holding the data | |
// as allData. | |
// The matrix has n rows and m columns. Column numbers go from 1 to m, row numbers go from 1 to n. | |
// allData[i] gives the row at index i. A cell on row index i, col index j, can be accessed as allData[i][j]. | |
// Column k is the 'Key' column containing strings. Assume the keys are unique for each row. | |
// Rest of the cells can contain numbers or strings. |
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 maxEnvelopes = function(envelopes) { | |
let dollArray = []; | |
envelopes.forEach((element) => { | |
if(typeof element === 'number') { | |
dollArray.push(element); | |
} else { | |
element.forEach(x => { | |
dollArray.push(x); | |
}) | |
} |
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 LFUCache(limit) { | |
this.storage = []; | |
this.limit = limit; | |
} | |
LFUCache.prototype.get = function(key) { | |
//we want to cycle through the list of objects | |
for ( let i = 0 ; i < this.storage.length ; i ++ ) { | |
//check if the key matches the key we are lookinf for | |
if ( this.storage[i][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
var isSubsequence = function(s, t) { | |
let slit = s.split(''); | |
for ( let i = 0 ; i < slit.length ; i ++ ) { | |
if ( !t.includes(slit[i]) ) { | |
return false; | |
} | |
} | |
return true; | |
}; |
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
import pubnub from 'pubnub'; | |
let pb = new Pubnub({ | |
publishKey: 'pub-c-34cc14b5-87bc-43e4-8c58-55f6f44ed513', | |
subscribeKey: 'sub-c-434cd75e-44a3-11e7-b6a4-02ee2ddab7fe' | |
}) | |
pubnub.subscribe({ | |
channel: 'bart_buddy', | |
callback: function(arg){console.log(arg);} |
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 doubleVowels = function(array) { | |
var vowels = ['a','e','i','o','u']; | |
for ( var i = 0 ; i < array.length ; i ++) { | |
if ( vowels.includes(array[i]) ) { | |
array.splice(i, 0, array[i]); | |
i ++; | |
} | |
} | |
return array; |
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 productExceptSelf = function(nums) { | |
let output = []; | |
for ( let i = 0 ; i < nums.length ; i++ ){ | |
output.push(nums.reduce((x, y) => x + y) - nums[i]); | |
} | |
return output; | |
}; |
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 kthSmallest = function(root, k) { | |
var potentialSmall = root.val; | |
var counter = 0; | |
var numbers = [root.val]; | |
var go = true; | |
var test = function(x){ | |
if( !x.right || !x.left ){ | |
return numbers; | |
} else { |
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 CashAmount = (amount) => { | |
this.amount = amount.toFixed(2); | |
} | |
CashAmount.prototype.totalInPennies = function() { | |
var amountInPennies = this.amount.toString().split(""); | |
amountInPennies.splice(-3,1); |
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 CashAmount = (amount) => { | |
this.amount = amount.toFixed(2); | |
} | |
CashAmount.prototype.totalInPennies = function() { | |
var amountInPennies = this.amount.toString().split(""); | |
amountInPennies.splice(-3,1); |