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
import axios from 'axios' | |
// a proxy server is not always needed for all sites | |
// though in some cases, sites will restrict access to those that are not same-origin | |
// in such case, proxy servers can be used to bypass, as seen here using https://cors-anywhere.herokuapp.com/. | |
axios.get('https://cors-anywhere.herokuapp.com/https://designboom.com', { crossdomain: true }).then((response) => { | |
// returns raw html which can be used subsequently as DOM nodes | |
console.log(response.data) |
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
var stack = [] | |
stack.push(1) | |
console.log(stack) | |
stack.pop() | |
console.log(stack) | |
var queue = [] |
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
// From ThatJSDude | |
function linkedList () { | |
this.head = null | |
this.length = 0 | |
} | |
linkedList.prototype.push = function (val) { | |
var node = { | |
value: val, |
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
// from Tutsplus, https://code.tutsplus.com/articles/data-structures-with-javascript-singly-linked-list-and-doubly-linked-list--cms-23392 | |
function Node(data) { | |
this.data = data; | |
this.next = null; | |
} | |
function SinglyList() { | |
this._length = 0; | |
this.head = null; |
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
// From ThatJSDude, http://thatjsdude.com/interview/linkedList.html#singlyLinkedList | |
function linkedList () { | |
this.head = null | |
} | |
linkedList.prototype.push = function (val) { | |
var node = { | |
value: val, | |
next: null |
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
.contain::before { | |
content: ''; | |
width: 100%; | |
height: 660px; | |
z-index: -1000; | |
background: linear-gradient(to bottom right, #F7F7F7, #EAFBFF); | |
transform-origin: left bottom; | |
position: absolute; | |
top: 0; | |
left: 0; |
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
// Final solution | |
function mergeRanges (meetings) { | |
// sort by start time | |
var sortedMeetings = meetings.slice().sort(function (a, b) { | |
return a.startTime > b.startTime ? 1: -1 | |
}) | |
// initialize meetings with first from sorted meetings | |
var mergedMeetings = [sortedMeetings[0]] |
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 getProductsOfAllIntsExceptAtIndex (arr) { | |
var productsOfArr = [] | |
for (var i = 0; i < arr.length; i++) { | |
var clone = arr.slice(0) | |
var removed = clone.splice(i, 1) | |
productsOfArr.push(getProductOfArr(clone)); | |
} | |
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 getMaxProfit(stockPrices) { | |
var allPurchases = {} | |
var allPurchasesArr = [] | |
for (var i = 0; i < (stockPrices.length); i++) { | |
var stockClone = stockPrices.slice(0) | |
var currRemoved = stockClone.splice(0, i+1) | |
var maxStockRight = Math.max(...stockClone) | |
allPurchases[stockPrices[i]] = stockPrices[i] - maxStockRight |
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
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T. In research, it can be useful to identify repeated sequences within DNA. | |
Write a function to find all the 10-letter sequences (substrings) that occur more than once in a DNA molecule s, and return them in lexicographical order. These sequences can overlap. | |
Example | |
For s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT", the output should be | |
repeatedDNASequences(s) = ["AAAAACCCCC", "CCCCCAAAAA"]. | |
Input/Output |
NewerOlder