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
#!/bin/sh | |
### | |
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
### | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
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 readForFree() { | |
// select html element | |
// set overflow to auto | |
document.documentElement.style.overflow = 'auto'; | |
// LA times overlay id === reg-overlay | |
// set overlay to display: none !important | |
let overlayEl = document.getElementById('reg-overlay'); | |
overlayEl.style.setProperty('display', 'none', 'important'); | |
// 'remove' event listener from window |
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
let findMaxLength = function(nums) { | |
const map = new Map(); | |
map.set(0, -1); | |
let count = 0, | |
max = 0; | |
for(let i = 0; i < nums.length; i++) { | |
if(nums[i] === 0){ | |
count--; | |
} else { | |
count++; |
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
let lastStoneWeight = function(stones) { | |
// 2 pointers & index for tracking in array | |
let pointer1 = 0; | |
let pointer2 = pointer1 + 1; | |
let index = pointer2 + 1; | |
let weight1, weight2; | |
// reset pointers and weights | |
function resetValues() { | |
// reset pointers and weights |
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
/** | |
* Definition for a binary tree node. | |
* function TreeNode(val) { | |
* this.val = val; | |
* this.left = this.right = null; | |
* } | |
*/ | |
/** | |
* @param {TreeNode} root | |
* @return {number} |
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
class MinStack { | |
constructor() { | |
this.items = []; | |
} | |
push(item) { | |
this.items.push(item); | |
} | |
pop() { |
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
let backspaceCompare = function(S, T) { | |
let string_s = S.split('').reduce((acc, char, index) => { | |
if(char === '#') { | |
acc.pop(); | |
} else { | |
acc.push(char); | |
} | |
return acc; | |
}, []).join(''); |
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
/** | |
* Definition for singly-linked list. | |
* function ListNode(val) { | |
* this.val = val; | |
* this.next = null; | |
* } | |
*/ | |
let middleNode = function(head) { | |
let length = 1; |
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
let groupAnagrams = function(strs) { | |
let result = {}; | |
for(let i = 0; i < strs.length; i++) { | |
let word = strs[i]; | |
// sort the letters, join them together | |
let sortedWord = word.split('').sort().join(); | |
if(!result[sortedWord]){ | |
// if sortedWord is not in object | |
// set sorted as key and orig word as array value |
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
let countElements = function(arr) { | |
// returning a counter of times a number x + 1 | |
// is found in an array | |
let count = 0; | |
// need storage to keep track of x + 1 frequency | |
let storage = {}; | |
for(let num of arr){ | |
// if a number x + 1 is in the array | |
if(arr.indexOf(num + 1) > -1) { |
NewerOlder