Skip to content

Instantly share code, notes, and snippets.

View PantherHawk's full-sized avatar

Alexander Rosenthal PantherHawk

View GitHub Profile
function a() {
setTimeOut(function() {
console.log('a');
b();
}, 2000);
};
function a() {
setTimeOut(function() {
console.log('a');
b();
}, 2000);
};
function b() {
setTimeOut(function() {
console.log('b');
function a() {
setTimeout(function() {
console.log('a');
b();
}, 2000);
};
function b() {
setTimeout(function() {
getOpenGraph: function(req, res) {
console.log(req.body.url);
openGraph(req.body.url, function(err, meta) {
if (err) {
console.error(err);
} else {
res.send(meta);
}
});
},
//Generators
// Remember functions?
function doA() {
console.log('did A');
}
function doB() {
console.log('did B')
}
function justAFxn() {
decimalZip = (A, B) => {
if ( typeof A !== "number" || typeof B !== "number" ) {
return undefined;
}
var a = JSON.stringify(A).split('')
var b = JSON.stringify(B).split('')
var c = [];
var longer = a.length > b.length ? a : b;
for (var i = 0; i < longer.length; i++) {
if (a.length) {
//to go into a DOM trees we use document.childNodes
// we have to make a tree structure of the DOM
// traverse the DOM, and make a new tree for every node, and print the tree
class Tree {
constructor(val) {
this.val = val;
this.children = [];
}
https://repl.it/@pantherhawk22/2D-Matrix-Rotation
// rotate 2d grid 90 degrees
// o: 2d array rotated 90 degrees, counter clockwise
// i: 2d array, width = length
// c: no worse the O(n^2)
// PLAN:
// reverse order of rows
// replace the last column elements of each row with elements in the first row, until you reach the next to last

Requirements

Strategy

Advance two pointers along the linked list.

  • Pointer A moves one node at a time.
  • Pointer B moves two nodes at a time.
@PantherHawk
PantherHawk / Leet Code: median-of-two-sorted-arrays
Created December 5, 2017 13:57
Median of two sorted arrays implementation. For Leet Code.
var findMedianSortedArrays = function(nums1, nums2) {
// new tactic, merge sort the two arrays, and then find the median.
let sorted = mergeSort(nums1.concat(nums2));
if (sorted.length % 2 === 0) {
return handleEven(sorted);
}
return handleOdd(sorted);
}
function mergeSort(arr) {