This file contains hidden or 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
| // Place your settings in the file "Packages/User/Preferences.sublime-settings", | |
| // which overrides the settings in here. | |
| // | |
| // Settings may also be placed in syntax-specific setting files, for | |
| // example, in Packages/User/Python.sublime-settings for python files. | |
| { | |
| // Sets the colors used within the text area | |
| "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
| // Note that the font_face and font_size are overridden in the platform |
This file contains hidden or 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 factorial = (num) => { | |
| return num === 0 ? 1 : num * factorial(num-1) | |
| } |
This file contains hidden or 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 numCom = (x) => { | |
| return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
| } |
This file contains hidden or 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
| ##The Challenge | |
| Given a string S and a set of words D, find the longest word in D that is a subsequence of S. | |
| Word W is a subsequence of S if some number of characters, possibly zero, can be deleted from S to form W, without reordering the remaining characters. | |
| Note: D can appear in any format (list, hash table, prefix tree, etc. | |
| For example, given the input of S = "abppplee" and D = {"able", "ale", "apple", "bale", "kangaroo"} the correct output would be "apple" | |
| The words "able" and "ale" are both subsequences of S, but they are shorter than "apple". |
This file contains hidden or 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
| // ===== ANSWER | |
| function solution(H) { | |
| // write your code in JavaScript (Node.js 8.9.4) | |
| let stack = []; | |
| let count = 0; | |
| let height = 0; | |
| // adds a block to the stack when value exceeds current height | |
| const addBlock = (value) => { |
This file contains hidden or 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
| // ===== ANSWER: | |
| function solution(A) { | |
| let set = new Set(); // holds a unique set of values | |
| let max = 1; // largest number in set | |
| let min = 1; // smallest number in set | |
| let n = A.length | |
| for (let i = 0; i < n; i += 1) { | |
| let num = A[i]; |
This file contains hidden or 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 solution(X, Y, D) { | |
| let range = (Y - X); // max distance to go | |
| // special cases | |
| let hops = D === Y ? 0 : parseInt(range / D); // whole jumps [1] | |
| let extra = range % D; // any left over hops required | |
| console.log(`===>| X:${X} | Y:${Y} | D:${D} | range:${range} | hops:${hops} | extra:${extra} |`) | |
| return extra ? hops + 1 : hops | |
| } | |
| // [1] parseInt() [at least in Chrome] exhibits wonky behavior when working with small fractions. For example: |
This file contains hidden or 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
| // ANSWER: | |
| function solution(A) { | |
| // make a dictionary of expected values: O(n) | |
| let map = [] | |
| for (let i = 0; i < A.length + 1; i+= 1) { | |
| map[i] = { num: i+1, bool: -1 } | |
| } | |
| // evaluate subset against dictionary, marking included values: O(n) |
This file contains hidden or 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
| { | |
| "env": { | |
| "browser": true, | |
| "es6": true, | |
| "node": true, | |
| "jest": true | |
| }, | |
| "extends": [ | |
| "airbnb", | |
| "plugin:jsx-a11y/recommended", |
This file contains hidden or 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
| { | |
| "name": "date_trader", | |
| "version": "0.0.1", | |
| "description": "Basic CRUD template in React and Redux", | |
| "main": "index.js", | |
| "scripts": { | |
| "start": "react-scripts start", | |
| "build": "react-scripts build", | |
| "test": "react-scripts test --env=jsdom", | |
| "eject": "react-scripts eject" |