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
/** | |
* You can brute force and increment/decrement the given number until you find a valid-all-even-digits | |
* number, but the time complexity would be O(n) where n is value of the number. Instead, you | |
* can validate each digit starting with the highest power to come up with the nearest valid number. | |
* Since you can make a number even by going up or down, both paths have to be considered. | |
* | |
* For example, take 567; | |
* | |
* It won't matter what you do with '67' because '5' will always be invalid. So you have to make it even. |
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
var sampleArray = [[1,2,3],[[4],[5,6], [7,[8],9]], [10, 11], [12, [13, 14]]] | |
function flatten(array) { | |
var result = []; | |
recurseFlatten(array, result);; | |
return result; | |
} | |
function recurseFlatten(array, result) { | |
for (var i = 0; i < array.length; 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
const arr = [10, 12]; // for simplicity, let's only have 2 runs | |
for (let i = 0; i < arr.length; i++) { | |
setTimeout(() => { | |
console.log('The index of this number is: ' + i); | |
}, 3000); | |
} | |
// /////////////////////////////// | |
// example with the let keyword | |
// /////////////////////////////// | |
// the following is how a computer will run the above for loop |
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 arr = [10, 12, 15, 21]; | |
for (let i = 0; i < arr.length; i++) { | |
setTimeout(function() { | |
console.log('The index of this number is: ' + i); | |
}, 3000); | |
} | |
///////////////////////////////// | |
// example with the let keyword | |
///////////////////////////////// | |
// the following is how a computer will run the above for loop |
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 arr = [10, 12, 15, 21]; | |
for (let i = 0; i < arr.length; i++) { | |
setTimeout(function() { | |
console.log('The index of this number is: ' + i); | |
}, 3000); | |
} | |
///////////////////////////////// | |
// example with the let keyword | |
///////////////////////////////// | |
// the following is how a computer will run the above for loop |
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 { dispatch } from '~/store/store' | |
import PadawanApi from '~/actions/padawan-api' | |
const create = async (student) => { | |
dispatch({ | |
type: 'CREATE_STUDENT_START', | |
student | |
}) |
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 { dispatch } from '~/store/store' | |
import PadawanApi from '~/actions/padawan-api' | |
const create = async (student) => { | |
dispatch({ | |
type: 'CREATE_STUDENT_START', | |
student | |
}) |
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
dude, just copy the url |
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
shopt -s extglob | |
alias ll='ls -la' | |
alias redis='cd ~; redis-server /usr/local/etc/redis.conf' | |
alias ll_bower='ls -la bower_components' | |
# gits! | |
alias gfa="git fetch --all; gs" | |
# alias grh='git reset --hard; gl 10; gs' |
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
class Navigation extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
active: 'home', | |
}; | |
} | |
changeNavigation = (e, section) => { | |
e.preventDefault(); |
NewerOlder