Skip to content

Instantly share code, notes, and snippets.

@vinayverghese
vinayverghese / 1-isomorphic.js
Last active August 20, 2018 20:34 — forked from primaryobjects/1-isomorphic.js
Isomorphic Strings
/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isIsomorphic = function(s, t) {
var result = true;
if (s.length === t.length) {
var hash1 = [];
@vinayverghese
vinayverghese / makeChange.js
Created August 20, 2018 19:45 — forked from furf/makeChange.js
Given a set of coin denominators, find the minimum number of coins to give a certain amount of change.
function makeChange (amount) {
var change = {},
i = 0,
coins = makeChange.COINS,
coin;
while (amount && (coin = coins[i++])) {
if (amount >= coin) {
change[coin] = ~~(amount / coin);
// Using the JavaScript language, have the function RunLength(str) take the str parameter being passed and return a compressed // version of the string using the Run-length encoding algorithm. This algorithm works by taking the occurrence of each
// repeating character and outputting that number along with a single character of the repeating sequence.
// For example: "wwwggopp" would return 3w2g1o2p. The string will not contain any numbers, punctuation, or symbols.
// Input = "aabbcde" Output = "2a2b1c1d1e"
// Input = "wwwbbbw" Output = "3w3b1w"
function RunLength( str ) {
var output = '';
while ( str.length > 0 ) {