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
// 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 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
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
[ | |
{ | |
"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 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 = []; |
NewerOlder