Skip to content

Instantly share code, notes, and snippets.

Michael Tran Mike-Tran

Block or report user

Report or block Mike-Tran

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Mike-Tran
Mike-Tran / System Design.md
Created Jan 24, 2019 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
View es6-map-to-object-literal.js
let map = new Map();
map.set("a", 1);
map.set("b", 2);
map.set("c", 3);
let obj = Array.from(map).reduce((obj, [key, value]) => (
Object.assign(obj, { [key]: value }) // Be careful! Maps can have non-String keys; object literals can't.
), {});
console.log(obj); // => { a: 1, b: 2, c: 3 }
View oneArray
function oneArray(arr) {
return arr.reduce(function (first, next) {
return first.concat(Array.isArray(next) ? oneArray(next) : next);
}, []);
}
oneArray([[1,2,[3]],4]);
View FrogJump.js
function solution(X, A) {
// write your code in JavaScript (Node.js 0.12)
var count = new Array(X);
for ( var i=0; i < A.length; i++) {
var info = {
minute : i,
count : 1
};
View MushroomPicker
Given non empty, zero indexed array (A)
A has n integers (1 < n < 100000)
A represents number of mushrooms growing in a consecutive spots along the road
Given integers k and m
k = spot on the road and m = number of moves
In one move, she moves to an adjacent spot
View Prefix Sums
function prefixSums(A){
var leng = A.length;
p = [0] * (leng +1);
for(var i = 0; i< leng+1; i++){
P[i] = P[i-1] + A[i-1];
}
return P;
}
View MaxCounters.js
/*
You are given N counters, initially set to 0, and you have two possible operations on them:
increase(X) counter X is increased by 1,
max counter all counters are set to the maximum value of any counter.
A non-empty zero-indexed array A of M integers is given. This array represents consecutive operations:
if A[K] = X, such that 1 X N, then operation K is increase(X),
if A[K] = N + 1 then operation K is max counter.
View Missing Integer
function solution(A) {
var min = 1;
A.sort(function(a,b){
// Sort the array explicit way
return a - b;
});
for (var i in A) {
if (A[i] > -1 && A[i] == min) {
min++;
View tapeEqualibrium.js
function tapeEquilibrium(A) {
var p, i;
var leftSum = 0, rightSum = 0;
var totalSum = 0;
var lastMin, currentMin;
var leng = A.length;
if (leng == 2) { return Math.abs(A[0] - A[1]); }
if (leng == 1) { return Math.abs(A[0]); }
//edge cases where the length is 1 or 2
@Mike-Tran
Mike-Tran / The Technical Interview Cheat Sheet.md
Created Oct 11, 2016 — 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.
View The Technical Interview Cheat Sheet.md

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
You can’t perform that action at this time.