Skip to content

Instantly share code, notes, and snippets.

View johntran's full-sized avatar
🌈
Make it last forever, FRIENDSHIP NEVER ENDS

johntran

🌈
Make it last forever, FRIENDSHIP NEVER ENDS
View GitHub Profile

https://gist.github.com/johntran - > big2019Feb19.md

Algorithms 2019 02 19

systems

Problem Set

SumZero

Given an array of positive and negative numbers, find if there is a subarray (of size at-least one) with 0 sum and return the subarray.

export default function useToggle(initial = false) {
const [open, setToggle] = useState(initial);
return {
open,
set: setToggle,
setOpen: () => setToggle(true),
setClose: () => setToggle(false),
reset: () => setToggle(initial),
toggle: () => setToggle(prev => !prev),
};
@johntran
johntran / functionHoisting.js
Created December 16, 2019 23:02
Function Hoisting: Assume that `foo` is the main function
export default function foo() {
return bar();
}
function bar() {
return baz();
}
function baz() {
return 42;