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 deepCopy(source) { | |
return deepCopyHelper(source, {}); | |
} | |
function deepCopyHelper(source, target) { | |
for(let key in source) { | |
const value = source[key]; | |
if(typeof value !== "object") { | |
target[key] = value; | |
} 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
function kmpSearch(str, pattern) { | |
var arr = calculatePrefixTable(pattern); | |
var j = 0; | |
var i = 0; | |
var index = -1; | |
var len = pattern.length; | |
var strLength = str.length; | |
while(i < strLength) { | |
if(str.charAt(i) === pattern.charAt(j)) { | |
i++; |
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
<link rel="shortcut icon" href="favicon.ico" /> | |
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon.png" /> | |
<link rel="msapplication-TileColor" href="#0074ba" /> | |
<link rel="msapplication-TileImage" href="/mstile-144x144.png" /> |
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
const HtmlWebPackPlugin = require('html-webpack-plugin'); | |
const autoprefixer = require('autoprefixer'); | |
const path = require('path'); | |
module.exports = { | |
entry: __dirname + "/src/client/index.js", | |
devtool: "cheap-eval-source-map", | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'client.bundle.js', |
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 Cache(maxSize) { | |
this.data = []; | |
this.maxSize = maxSize; | |
this.size = 0; | |
this.put = function(key, value, ttl) { | |
if(value.length > this.maxSize) { | |
throw new Error('string is too large'); | |
} |
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
<input id="inputText" type="text" /> | |
function DataBind(domElement, object) { | |
this.element = domElement.element; | |
this.attribute = domElement.attribute; | |
this.event = domElement.event; | |
this.value = this.element[this.attribute]; | |
var self = this; |
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
1. https://www.geeksforgeeks.org/top-10-algorithms-in-interview-questions/ | |
2. Dynamic Programming for Coding Interviews: A Bottom-Up Approach to Problem Solving | |
3. Narasimha karumanchi - Algorithms | |
4. https://www.hiredintech.com/system-design/ | |
5. Design from https://github.com/jwasham/coding-interview-university |
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
1. Write poly-fill of Object.create and explain why it worked: | |
if(typeof Object.create != "function") { | |
Object.create = function(param) { | |
var Fun = function(){}; | |
Fun.prototype = param; | |
return new Fun(); | |
} | |
} |
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
//index.js | |
var Project = function() { | |
this.info = {}; | |
this.setValues = function(info) { | |
for(var prop in info) { | |
if(this.info[prop] !== 'undefined') { | |
this.info[prop] = info[prop]; | |
} | |
} | |
}; |
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
//index.js | |
var Project = function() { | |
this.info = {}; | |
this.setValues = function(info) { | |
for(var prop in info) { | |
if(this.info[prop] !== 'undefined') { | |
this.info[prop] = info[prop]; | |
} |
NewerOlder