Divide two integers without using multiplication, division and mod operator.
思路:1.先将被除数和除数转化为long的非负数,注意一定要为long,因为Integer.MIN_VALUE的绝对值超出了Integer的范围。
2.常理:任何正整数num都可以表示为num=2^a+2^b+2^c+.....
分类:
其他好文 时间:
2014-06-25 19:46:17
阅读次数:
246
Peterson's algorithm (AKA Peterson's solution) is a concurrent
programming algorithm for mutual
exclusion that allows two processes to share a single-use resource without conflict, using only shar...
分类:
编程语言 时间:
2014-06-25 19:38:19
阅读次数:
748
Android开发环境搭建时遇到问题的解决方法
错误1:
The connection to adb is down, and a severe error has occured.
[2013-08-31 16:11:56 -com.qihoo.subject]
You must restart adb and Eclipse.
[2013-08-31 16:11:56...
分类:
移动开发 时间:
2014-06-24 23:51:52
阅读次数:
514
Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using e...
分类:
其他好文 时间:
2014-06-24 23:30:08
阅读次数:
278
【题目】
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
Note:
You may not engage in multiple transactions at the same time (i...
分类:
其他好文 时间:
2014-06-24 23:28:43
阅读次数:
223
1.Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in you
r Gemfile
2.ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/lib/ruby/gems/1.9.1 director.y
3.rails 3遇到 Could n...
分类:
其他好文 时间:
2014-06-24 22:18:45
阅读次数:
316
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder it t...
分类:
其他好文 时间:
2014-06-24 21:55:30
阅读次数:
279
1.以oracle用户登录oracle数据库,执行如下命令登录数据库:
sqlplus / as sysdba
2.运行如下命令:
@?/rdbms/admin/awrrpt.sql
3.出现如下信息时,直接回车(默认HTML格式)
Would you like an HTML report, or a plain text report?
4.出现如下信息时,直接回车
Enter ...
分类:
其他好文 时间:
2014-06-24 21:30:53
阅读次数:
226
我们知道字符串用字符数组或用指针实现,可是在赋值的时候产生了不少疑惑
用法一:
char a[ ]={"I LOVE YOU!"};
可是下面这样就是错的:
char a[20];
a={"I LOVE YOU!"};
用法二:
char a[]="I LOVEYOU";
用法三:
char *a="I LOVE YOU"
用法四:针对一中的错误用法,可用str...
分类:
其他好文 时间:
2014-06-24 19:10:31
阅读次数:
397
【题目】
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama" is a palindrome.
"race a car" is not a palindrome.
Note:
Have you consider that the string m...
分类:
其他好文 时间:
2014-06-24 15:35:07
阅读次数:
150