[ 问题: ]
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were
inserted in order. You may assume no duplicates in th...
分类:
其他好文 时间:
2014-07-22 23:01:15
阅读次数:
270
Excuses, Excuses!
Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame excuses in order to avoid serving. In order to reduce the amount of time requi...
分类:
其他好文 时间:
2014-05-02 23:54:43
阅读次数:
474
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link...
分类:
其他好文 时间:
2014-05-01 22:08:19
阅读次数:
366
You are given two linked lists representing two
non-negative numbers. The digits are stored in reverse order and each of their
nodes contain a single ...
分类:
其他好文 时间:
2014-05-01 20:18:54
阅读次数:
425
题目:
Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height.
翻译:
给定一个有序数组(递增),写程序构建一棵具有最小高度的二叉树。
思路:
要使二叉树的高度最小,则要尽量使其左右子树的节点数目相当,自然就考虑到将其构造成为二叉排序树,且将有序数组的中间大的数作为根节点,这样得到的二叉树的高度便是最小的。...
分类:
其他好文 时间:
2014-05-01 17:48:45
阅读次数:
321
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by
涉及的列上建立索引。2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如:select id from
t where num is null可以在num...
分类:
数据库 时间:
2014-05-01 13:23:55
阅读次数:
443
innodb的事务隔离级别是可重复读级别且innodb_locks_unsafe_for_binlog禁用,也就是说允许next-key
lockCREATETABLE`LockTest`(`order_id`varchar(20)NOTNULL,`id`bigint(20)NOTNULLAUTO_...
分类:
数据库 时间:
2014-05-01 12:39:14
阅读次数:
645
Problem 1:Given a set of distinct integers, S,
return all possible subsets.Note:Elements in a subset must be in non-descending
order.The solution set ...
分类:
其他好文 时间:
2014-05-01 09:43:43
阅读次数:
414
The variables are guaranteed to be laid out
contiguously, as in C. However, the access blocks may not appear in the object
in the order that you decla...
分类:
数据库 时间:
2014-05-01 04:11:22
阅读次数:
543
又是一个新的算法,原来可以这样查找的。
我的一句话理解的思想:
计算可以抵消的数量,那么如果一个数出现的次数超过半那么最终这个数肯定不会被抵消完。
这个思想叫 Moore’s Voting Algorithm
有了这个思想武器之后,程序就可以写的很简单,可以很清楚看到怎么实现的,
参考资料可以看:...
分类:
其他好文 时间:
2014-04-29 13:22:22
阅读次数:
260