Skip to content

Instantly share code, notes, and snippets.

@KodjoSuprem
KodjoSuprem / compute_change.js
Created November 29, 2016 09:29
coin change problem / Knapsack problem
var coinTypes = [25, 10, 5];     
var coinNb = [8, 12, 20]; 
function computeChange(change,coinTypes, coinNb) {   
var rez = [];   
for (var i = 0; i < coinTypes.length; ++i) {       
if (coinTypes[i] === 0) continue;       
var coinsToGet = Math.floor(change / coinTypes[i]);       
if (coinsToGet > coinNb[i]) {           
coinsToGet = coinNb[i];       
}       
@KodjoSuprem
KodjoSuprem / The Technical Interview Cheat Sheet.md
Last active November 8, 2016 23:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Data Structure Basics

####When to use collection container?

  • Consider complexity of operations (insert , search, etc..)
  • Use cases (order matter, FIFO, etc...)
  • Memory footprint

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
@KodjoSuprem
KodjoSuprem / handsontable_selection_area_background_hook.js
Last active August 31, 2016 10:54
Stack handsontable cells area selection background with existing cell background images
Handsontable.hooks.add('beforeInitWalkontable', function (walkontableConfig) {
var areaSelection = walkontableConfig.selections.area;
var oldDraw = areaSelection.draw;
var olAddClassAtCoords = areaSelection.addClassAtCoords;
areaSelection.draw = function (wotInstance) {
var nodes = wotInstance.wtTable.TABLE.querySelectorAll('.custarea');
for (var i = 0, len = nodes.length; i < len; i++) {
var TD = nodes[i];
TD.removeAttribute("style"); //use this for IE
wotInstance.wtTable.removeClassFromCells("custarea");