June 8, 2015 我最喜欢的一道算法题目, 二行代码. 编程序需要很强的逻辑思维, 严密,我还没有很好训练自己.想一想, 二行代码, 五分钟就可以搞定; 最近这几天网上大家热议的 Homebrew 的作者 Max Howell 面试 Google 挂掉的一题, 二叉树反转, 七行代码, 相比二行代码, 情有可原!   One solution (Cannot pass the phone interview - need to improve, show reasoning, logic…
eval函数接收一个参数s,如果s不是字符串,则直接返回s.否则执行s语句.如果s语句执行结果是一个值,则返回此值,否则返回undefined. 需要特别注意的是对象声明语法“{}”并不能返回一个值,需要用括号括起来才会返回值,简单示例如下: 复制代码 代码如下:var code1='"a" + 2'; //表达式 varcode2='{a:2}'; //语句 alert(eval(code1)); //->'a2' alert(eval(code2)); //->unde…
Invalid default value for prop "value": Props with type Object/Array must use a factory function to return the default value.(百度翻译:PROP“值”的默认缺省值:Type对象/数组的PROPS必须使用工厂函数返回默认值.) props default 数组/对象的默认值应当由一个工厂函数返回…
function $(id) {   return typeof id === "string" ? document.getElementById(id) : id; } 这句代码什么意思? 如果id的数据类型是string 就返回 对应的id的html元素,否则返回id本身的值 表达式1?表达式2:表达式3 这是一个式子:他的运算过程是:先计算表达式1,如果为true,这个式子就取表达式2的运算结果,否则整个式子取值就是表达式3的运算结果 在你这个例子中 表达式1是 "s…
[].slice.call(k).filter(function(l) { return l != 0 }); 将类数组调用数组方法.…
Invalid default value for prop "value": Props with type Object/Array must use a factory function to return the default value.(props default 数组/对象的默认值应当由一个工厂函数返回) 正确书写方式 <script> export default{ props:{ list:{ type: [Object,Array], default:…
1094 - Farthest Nodes in a Tree PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges of the tree are weighted and undire…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1094 Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges of the tree are weighted and undirected. That means you have to find two nodes in…
http://lightoj.com/volume_showproblem.php?problem=1094 Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges of the tree are weighted and undirected. That means you have to find two nodes in the t…
Farthest Nodes in a Tree Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Status Description Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges of the tree are weigh…