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 text = ` | |
vue-cli - Simple CLI for scaffolding Vue.js projects. | |
Vue Plugin Boilerplate - Boilerplate for Vue.js plugin. | |
Bourgeon - Bourgeon is an opinionated-featured VueJS 2.0 setup for Webpack. | |
VuePack - A modern starter which uses Vue 2, Vuex, Vue-router and Webpack 2 (and even Electron). | |
` | |
text = text.trim().split("\n"); | |
var object = {} | |
var items = []; |
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
[ | |
{ | |
"description": "", | |
"link": "", | |
"tags": [ | |
"First tag", | |
"Second tag" | |
], | |
"title": "Official Guide" | |
}, |
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 val = fetchAllKids('9153') | |
// console.log(val); | |
function fetchAllKids(link, parent){ | |
var uniqueID = link | |
var localLink1 = 'https://hacker-news.firebaseio.com/v0/item/' + uniqueID + '.json?' | |
axios.get(localLink1, uniqueID) |
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 Node (value) { | |
this.next = null; | |
this.value = value; | |
} | |
function LinkedList (headValue) { | |
if (headValue === undefined) console.log("Head must be defined"); | |
this.head = new Node(headValue); | |
this.tail = this.head; | |
} |
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
// Codefights Prompt | |
You have a list of dishes. Each dish is associated with a list of ingredients used to prepare it. You want to to group the dishes by ingredients, so that for each ingredient you'll be able to find all the dishes that contain it (if there are at least 2 such dishes). | |
Return an array where each element is a list with the first element equal to the name of the ingredient and all of the other elements equal to the names of dishes that contain this ingredient. The dishes inside each list should be sorted lexicographically. The result array should be sorted lexicographically by the names of the ingredients in its elements. | |
Example | |
For | |
dishes = [["Salad", "Tomato", "Cucumber", "Salad", "Sauce"], | |
["Pizza", "Tomato", "Sausage", "Sauce", "Dough"], |
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 sumOfTwo(a, b, v) { | |
a.sort() | |
b.sort() | |
for(i in a) { | |
var target = v - a[i] | |
if (binary_Search(b, target) > -1) { | |
console.log(target) | |
return true | |
} |
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 |
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
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
// 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]] |
OlderNewer