- Given a binary tree, check if its a BST. A valid BST doesn't have to be complete or balanced. Duplicate elements are not allowed in a BST.
- Solution runtime: O(N) time where N is the number of nodes in the tree.
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
describe('Guest User Can Make Order Receipt', () => { | |
it('can visit app', () => { | |
return cy.visit('https://www.onehopewine.com/shop/wine/wine'); | |
}); | |
it('can add item', () => { | |
return cy | |
.get('#ProductScroll') | |
.find('.AddToCartButton') | |
.first() | |
.click() |
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
// Exponential Laws | |
// B^(x+y) = B^x * B^y | |
// B^(x*2) | |
function addTimeOrTemp(x, isTime) { | |
if (isTime) { | |
this.time += x; | |
return this.time; | |
} else { |
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
// AC + AD + BC + BD = (A+B)(C+D) | |
// Currently AC + AD + BC + BD | |
function intersect([low1, hi1], [low2, hi2]) { | |
if (low1 > low2) { | |
if (hi1 < hi2) { | |
return [low1, hi1]; | |
} else { | |
return [low1, hi2]; | |
} |
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
import * as React from 'react'; | |
import {withFeatureFlags} from './FeatureFlag' | |
@withFeatureFlags(['TEMP_20180523_123_DELETE_PAYMENTS']) | |
class EditPaymentDialog extends React.Component<{}, {}> { | |
render() { | |
const { featureFlags } = this.props; | |
const { TEMP_20180523_123_DELETE_PAYMENTS } = featureFlags; | |
if (TEMP_20180523_123_DELETE_PAYMENTS) return <div />; | |
return null; |
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 getBillingAddress({ | |
firstName, | |
lastName, | |
street, | |
addressLineTwo, | |
city, | |
state, | |
zip, | |
} ) { | |
return { |
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 foobar = factors => | |
factors.map(factor => | |
factors.map(secondFactor => | |
factor * secondFactor | |
) | |
); | |
var foobar = function(factors) { | |
return factors.map(function(factor) { | |
return factors.map(function (secondFactor) { |
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
{ | |
"scripts": { | |
"lint": "eslint server", | |
"lint:fix": "npm run lint -- --fix", | |
"prettier": | |
"./node_modules/.bin/prettier --single-quote --trailing-comma all --write \"{,!(node_modules|build|dist|flow-typed)/**/}*.js\"", | |
"prettierTS": | |
"./node_modules/.bin/prettier --single-quote --trailing-comma all --write \"{,!(node_modules|build|dist|flow-typed)/**/}*.ts\"", | |
"prettierTSX": | |
"./node_modules/.bin/prettier --single-quote --trailing-comma all --write \"{,!(node_modules|build|dist|flow-typed)/**/}*.tsx\"", |
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
/** | |
https://lodash.com/docs/4.17.4#flattenDeep | |
Recursively flattens array. | |
_.flattenDeep([1, [2, [3, [4]], 5]]); | |
// => [1, 2, 3, 4, 5] | |
Even if I nest an element 100 levels deep, it should still flatten it. | |
*/ |
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
/** | |
https://lodash.com/docs/4.17.4#memoize | |
Create a function that saves previous results of past calls. | |
Example: | |
function add(x,y) { | |
return x + y | |
} | |
const memoizedAdd = memoize(add); |