Skip to content

Instantly share code, notes, and snippets.

View WeiGrand's full-sized avatar
🏊‍♂️
Confusing

Weiguang WeiGrand

🏊‍♂️
Confusing
View GitHub Profile
/**
* Get all solutions of `n queens` problem
* https://zh.wikipedia.org/wiki/%E5%85%AB%E7%9A%87%E5%90%8E%E9%97%AE%E9%A2%98
* @param n
* @returns {*}
* @constructor
*/
const Nqueens = n => {
if (typeof n !== 'number') {
console.warn('Expect `n` to be a number got ' + typeof n + '.');
@WeiGrand
WeiGrand / react-fiber-stack.js
Last active June 25, 2019 12:23
Fiber (虚拟栈实现)
const a1 = {name: 'a1', child: null, sibling: null, return: null};
const b1 = {name: 'b1', child: null, sibling: null, return: null};
const b2 = {name: 'b2', child: null, sibling: null, return: null};
const b3 = {name: 'b3', child: null, sibling: null, return: null};
const c1 = {name: 'c1', child: null, sibling: null, return: null};
const c2 = {name: 'c2', child: null, sibling: null, return: null};
const d1 = {name: 'd1', child: null, sibling: null, return: null};
const d2 = {name: 'd2', child: null, sibling: null, return: null};
a1.child = b1;