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
to speed up html page load | |
<script async> #as long as the script doesn't affect the DOM | |
<script defer> #waits as long as it takes for the html to load (third party script that aren't that important) | |
Critical Render Path loading: HTML -> CSS -> Javascript, and JS can pause finishing of html if not careful | |
//testing sites |
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
// if you only need media for certain screen sizes: | |
<link rel="stylesheet" href:"./style2.css" media="only screen and (min-width:500px)"> | |
// so, at a minimum width of 500px, browser will load the style2.css | |
// and with CSS specificity can slow stuff down: | |
/* bad */ | |
.header .nav .item .link a.important { |
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
<script type="text/javascript"> | |
const loadStyleSheet = src => { | |
if(document.createStyleSheet) { | |
document.createStyleSheet(src) | |
} else { | |
const stylesheet = document.createElement('link'); | |
stylesheet.href = src; | |
stylesheet.type = 'text/css'; | |
stylesheet.rel = 'stylesheet'; | |
document.getElementsByTagName('head')[0].appendChild(stylesheet) |
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 array1 = ['a', 'c', 'g', 'x'] | |
const array2 = ['z', 'y', 'a'] | |
// Naive | |
function hasPairWithSum(arr, sum) { | |
var len = arr.length; | |
for(var i =0; i<len-1; i_++){ | |
for (var j = i+1; j<len; j++){ | |
if (arr[i] + arr[j] === sum) | |
return true; |
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
find matching pair that equals a sum from a collection of numbers | |
[1,2,3,9] Sum =8 | |
[1,2,4,4] Sum =8 | |
how are these numbers given: memory/array? | |
repeating elements? can i repeat the same element? --same number might occur twice | |
are these integers or floats -- ints | |
can they be negative -- Yes | |
are they sorted? -- yes |
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
Sorting | |
Dynamic Programming | |
BFS + DFS (Searching) | |
Recursion |
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
Arrays | |
Stacks | |
Queues | |
Linked Lists | |
Trees | |
Tries | |
Graphs | |
Hash Tables |
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
1. Readable | |
2. Scalable Speed: Time Complexity = Big O | |
3. Scalable Memory: Space Complexity) = Big O | |
All three have trade-offs. | |
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
// Rules: | |
//1: Worst Case | |
//2: Remove Constants | |
//3: Different terms for inputs | |
//4: Drop Non Dominant terms (n's) => 0(x^2+3x+100+x/2) becomes 0(x^2) | |
function doSomething(array1, array2) { | |
array1.forEach(function(array1) { | |
console.log(array1); | |
}) |
NewerOlder