描述:
A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of the peaks is f...
分类:
其他好文 时间:
2015-05-15 09:03:58
阅读次数:
134
描述:
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.
For example, given the range [5, 7], you should return 4.
思路:
由于相邻的两个数最低位肯定有0有1,所以直接and肯定为0,所以可以通过直接and来和向右移位获得一个区间内的相同的位数,最后再通过向左...
分类:
其他好文 时间:
2015-05-15 09:03:20
阅读次数:
104
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number...
分类:
其他好文 时间:
2015-05-14 23:24:41
阅读次数:
137
一般的网站都会有都会有搜索的功能,一般实现搜索主要有三种方案第一种是最差的,也是最不推荐的,使用数据库的模糊查询例如select * form table where 字段 like XXX,这种查询的缺点很明显:(1) 无法查找几个关键词不连在一起的情况(2) 全表扫描 效率低下第二种:使用Sql...
分类:
Web程序 时间:
2015-05-14 21:58:13
阅读次数:
264
-实现删除学生信息时把该学生的成绩记录全部清空--判断触发器是否存在if exists(select * from sysobjects where name = 'delete_student')drop trigger delete_studentgocreate trigger delete_...
分类:
其他好文 时间:
2015-05-14 18:10:17
阅读次数:
105
Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo...
分类:
移动开发 时间:
2015-05-14 18:08:31
阅读次数:
231
二.查询缺少值的查询在这里我们加入要查询2008年每一天的订单有多少?首先我们可以查询下订单表的订单日期在2008年的所有订单信息。1 select distinct orderdate,count(*) as N'每日订单量' from sales.orders2 where orderdat.....
分类:
数据库 时间:
2015-05-14 15:53:42
阅读次数:
230
select 字段1,字段2,字段3 into tempname form table where table.id=1;这个会给tempname 表中自动生成字段1,字段2,字段3 三个字段以及值。修改表字段值,根据nidupdate tablename set 字段1=tb.ssm from (...
分类:
数据库 时间:
2015-05-14 15:41:47
阅读次数:
192
update T_Sys_Partner set EXPIREDATE = convert(nvarchar,year(EXPIREDATE))+'-'+'6' + right(convert(nvarchar(19),EXPIREDATE ,120),12) WHERE MONTH(Expire....
分类:
数据库 时间:
2015-05-14 15:37:12
阅读次数:
374
在用Atom写项目,同时用到grunt做自动化,当然就想到在atom直接调用grunt,有一个现成的atom plugin叫grunt-runner,安装后,需要配置一下,而且对于mac最新的OS X 10.10还需要特别注意: Find where grunt is in...
分类:
其他好文 时间:
2015-05-14 14:33:03
阅读次数:
123