Skip to content

Instantly share code, notes, and snippets.

View JacksonRMC's full-sized avatar

JacksonRMC

View GitHub Profile
@JacksonRMC
JacksonRMC / realization_coding_assessment.js
Created December 28, 2017 19:33
Coding challenge for Realization. Jackson Carter
// 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.
var maxEnvelopes = function(envelopes) {
let dollArray = [];
envelopes.forEach((element) => {
if(typeof element === 'number') {
dollArray.push(element);
} else {
element.forEach(x => {
dollArray.push(x);
})
}
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] ) {
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;
};
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);}
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;
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;
};
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 {
var CashAmount = (amount) => {
this.amount = amount.toFixed(2);
}
CashAmount.prototype.totalInPennies = function() {
var amountInPennies = this.amount.toString().split("");
amountInPennies.splice(-3,1);
var CashAmount = (amount) => {
this.amount = amount.toFixed(2);
}
CashAmount.prototype.totalInPennies = function() {
var amountInPennies = this.amount.toString().split("");
amountInPennies.splice(-3,1);