return

【算法之美】logn 时间复杂度求解两个有序数组的中位数

一道非常经典的题目,Median of Two Sorted Arrays。(PS:leetcode 我已经做了 190 道,欢迎围观全部题解 https://github.com/hanzichi/leetcode)题意非常简单,给定两个有序的数组,求中位数,难度系数给的是 Hard,希望的复杂度是 log 级别。回顾下中位数,对于一个有序数组,如果数组长度是奇数,那么中

Same Tree(100)

Same Tree Given two binary trees, write a function to check if they are equal orTwo binary trees are considered equal if they are structurallyand the nodes have the same value.思路: recursio

在非阻塞IO下的nodejs下的同步并行 ES6的 promise 从入门深入(二)

看过 (一)的同学一定觉得这个Promise很简单,好像没什么可以用的地方,但是事实上,它的用处非常大啊,尤其是在nodejs上,愈加重要,虽然已经有大量的库实现了对Promise的封装了,不过我还是更倾向用原生的node来实现对Promise的实现。现在我们要用的重点就是我们的Promise.all,这是一个能让函数并行的promise,可以基于多个Promise。我们讲

arguments.callee

一道面试题:有一个 n = 5 不用for 循环 返回[1,2,3,4,5]数组 function arr(n){var list = [];return (function(){list.unshift(n);n --;if (n !== 0 ){arguments.callee()};return list}()); } console.log(arr(5)) //[

React技术栈——ReactJS

初始化引入三个script:第一个是React的核心代码,第二react-dom.js是React里面操作DOM的部分,第三个browser.js将JSX转为Javascript语法。ReactDOM.render将模板语言转为HTML语言,并插入DOMReactDOM.render( Test, document.body);组件组件类第一个字母必须大写var

[LeetCode] Integer Break

Problem Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example,

[LeetCode] Integer Break

Problem Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example,

常用js设计模式整理

在做canvas、webGL游戏时,很深切的感觉到,游戏编程玩的都是设计模式。架构没预先设计好,强耦合性代码在后期维护简直灾难。大型单页应用里,复杂度上升到一定程度时,没有适当的设计模式进行降耦,后续的开发也难以下手。而设计模式正是为了降耦而存在。参考《javascript设计模式》——曾探函数节流var throttle = function(fn, interval){

343. Integer Break

题目:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given