有时候在项目中我们需要检测当前连接在机子上的摄像头的数量,可以通过下面的代码实现,其中连接摄像头的最大数量maxCamNum可以任意修改:/** * Count current camera number */int countCamera() { int maxCamNum = 5; ...
分类:
其他好文 时间:
2015-03-12 06:24:36
阅读次数:
484
Counting number of enabled bits in uint32_t.. Here is a O(lg32) solution. Very smart, like bottom-up parallel tree post-order traversal.Solution from ...
分类:
其他好文 时间:
2015-03-12 06:22:18
阅读次数:
118
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly...
分类:
其他好文 时间:
2015-03-12 00:59:44
阅读次数:
113
首先,hive本身有一个UDF,名字是datediff。我们来看一下这个日期差计算的官方描述,(下面这个是怎么出来的):hive> desc function extended datediff;OKdatediff(date1, date2) - Returns the number of day...
分类:
其他好文 时间:
2015-03-11 23:18:48
阅读次数:
4792
--创建表SQL> create table tab (a number, b number); Table created.--插入数据SQL> begin 2 for i in 1..10000 loop 3 ...
分类:
数据库 时间:
2015-03-11 22:59:34
阅读次数:
206
标题:Number of 1 Bits通过率:40.0%难度: 简单Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming ...
分类:
其他好文 时间:
2015-03-11 21:31:23
阅读次数:
121
题意:
找一个小于N的最大的且符合题意的数。
题意的数为,通过缩减后是回文的数,所谓的缩减就是相同连续的数看做一个数,如“155451111”其实就是“15451”是符合题意的数。
思路:
通过数位dp,然后二分求解。
dp[i][j][k]代表第i位,已经放了j个数,最后长度是k的缩减回文数有几个。
然后需要一个ok[]数组代表放的数是什么,如果连续放相同的数就等于没放数。
遍历所...
分类:
其他好文 时间:
2015-03-11 19:45:12
阅读次数:
140
over不能单独使用,要和分析函数:rank(),dense_rank(),row_number()等一起使用。其参数:over(partition by columnname1 order by columnname2)含义:按columname1指定的字段进行分组排序,或者说按字段columnn...
分类:
数据库 时间:
2015-03-11 19:19:51
阅读次数:
173
在JS中四舍五入的函数 toFixed(n) , n为要保留的小数位数。n为0~20,当n超过20的时候,JS会出错。如果小数点前和要截取的前一位都是0时,不会按常理截取。 var h=0.07 h.toFixed(1)的值为0.0其实要解决这个问题,原来是不一定要重写js中的Number类...
分类:
Web程序 时间:
2015-03-11 19:11:35
阅读次数:
146
SELECT st_id FROM ( SELECT *,ROW_NUMBER() OVER( PARTITION BY st_code ORDER BY st_code ) AS num FROM dbo.t_student_info) a WHERE a.num>=2View Code给重复的信...
分类:
数据库 时间:
2015-03-11 18:41:04
阅读次数:
135