Skip to content

Instantly share code, notes, and snippets.

@rain84
rain84 / max-sub-array.airbnb.test.ts
Last active March 8, 2021 14:23
Question from "Airbnb": Given an array of integers, return the largest range, inclusive, of integers that are all included in the array. For example, given the array [9, 6, 1, 3, 8, 10, 12, 11], return (8, 12) since 8, 9, 10, 11, and 12 are all in the array.
import { maxSubArray, addToSet } from './max-sub-array.airbnb'
describe('MaxSubArray', () => {
let arr = []
test('should return on empty array', () => {
expect(maxSubArray(arr)).toBeUndefined()
})
test('should work on array.length === 1', () => {
import * as React from 'react'
import { PayPalButton } from 'react-paypal-button-v2'
import Typography from '@material-ui/core/Typography'
import { PAYMENT_GATEWAYS, YG_EMAIL_BASE } from 'config'
import { Checkout as CheckoutInterface } from 'lib/queries/generatedTypes/Checkout'
interface PaypalOrderParams {
@vbanurag
vbanurag / longestPalidrome.js
Created July 20, 2020 06:04
Given a string, return the length of the longest palindromic subsequence in the string.
//This problem was asked by Google.
//Given a string, return the length of the longest palindromic subsequence in the string.
//For example, given the following string:
// input:: MAPTPTMTPA
//Return 7, since the longest palindromic subsequence in the string is APTMTPA.
//Recall that a subsequence of a string does not have to be contiguous!
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e