在IE8下有个js错误,但是在其它浏览器下(Firefox, Chrome, IE9)下面都很正常。后来调试发现原因是在IE8下,js数组没有indexOf方法。 在使用indexOf方法前,执行一下下面的js, 原理就是如果发现数组没有indexOf方法,会添加上这个方法 if (!Array.p...
分类:
其他好文 时间:
2014-06-25 15:00:43
阅读次数:
168
/*求二叉树中距离最远的两个点 * 基本思路: * 递归计算两棵树的最大高度,设置一个全局变量,距离最远的两个节点element * 其中:在计算左子支,直接刷新上述全局变量,在计算右边子支时,设置两个临时Node变量,变量里的element用于 * 保存右边子支的两个最远距离。根据比较两个距离的大...
分类:
其他好文 时间:
2014-06-25 14:54:59
阅读次数:
247
使用device.js检测设备并实现不同设备展示不同网页html代码: 引入device.js(function() { var previousDevice, _addClass, _doc_element, _find, _handleOrientation, _hasClass...
分类:
移动开发 时间:
2014-06-25 14:07:19
阅读次数:
275
ruby comes with a set of predefined variables$: = default search path (array of paths)其他Ruby特殊变量:$! 最近一次的错误信息$@ 错误产生的位置$_ gets最近读的字符串$. 解释器最近读的行数(line...
分类:
其他好文 时间:
2014-06-25 13:55:51
阅读次数:
179
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
分类:
其他好文 时间:
2014-06-25 13:06:16
阅读次数:
198
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:
其他好文 时间:
2014-06-25 12:59:40
阅读次数:
202
题目:输入n个整数,找出其中最小的K个数方法一:直接std::sort,T(n) = O(nlgn)方法二:直接std::nth_element T(n) = O(n) 但是修改了原数组void MinKth(std::vector& num, int kth, std::vector& resul...
分类:
其他好文 时间:
2014-06-25 12:35:07
阅读次数:
216
/**
* Method 1: Delete the input element x
* and meanwhile keep the length of array after deleted n
* @param a the array
* @param n the length of array after deleted.
* @param x the element t...
分类:
其他好文 时间:
2014-06-25 08:27:27
阅读次数:
171
【题目】
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
For example,
Given [100, 4, 200, 1, 3, 2],
The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.
Your algorithm should run...
分类:
其他好文 时间:
2014-06-25 07:55:42
阅读次数:
244
"Could not find SQL statement to include with refid xxx"A: 认真把每个用到xxx的地方都看一遍
分类:
数据库 时间:
2014-06-25 00:58:20
阅读次数:
216