Problem Description
Here is a game for two players. The rule of the game is described below:
● In the beginning of the game, there are a lot of piles of beads.
● Players take turns to play. E...
分类:
其他好文 时间:
2014-09-14 23:42:04
阅读次数:
231
Problem Description
There is a special number sequence which has n+1 integers. For each number in sequence, we have two rules:
● ai ∈ [0,n]
● ai ≠ aj( i ≠ j )
For sequence a and sequence b, t...
分类:
其他好文 时间:
2014-09-14 23:41:28
阅读次数:
262
原题地址:https://oj.leetcode.com/problems/add-two-numbers/题意:You are given two linked lists representing two non-negative numbers. The digits are stored i...
分类:
编程语言 时间:
2014-09-14 23:17:17
阅读次数:
292
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 the array....
分类:
其他好文 时间:
2014-09-14 22:10:17
阅读次数:
146
AddType requires at least two arguments, a mime type followed by one or more file extensions
LoadModule takes two arguments, a module name and the na...
分类:
Web程序 时间:
2014-09-14 22:00:57
阅读次数:
404
二进制字符创相加,通过进位的方式逐位考虑。也可以把相加的过程抽象成一个函数。
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
方法一:
class Solution {
public:
s...
分类:
其他好文 时间:
2014-09-14 15:26:07
阅读次数:
285
设两个数组分别为A和B,size为as和bs。原问题可以转化为两个排序数组求第k大的问题。
还是两种思路:
比较A[as/2]和B[bs/2],每次抛弃A或者B的一半
代码如下:
double findMedianSortedArrays(int A[], int m, int B[], int n) {
int total = m + n;
if (tot...
分类:
其他好文 时间:
2014-09-14 12:53:37
阅读次数:
170
我写了两个版本供参考:
递归版本
ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) {
return addTwoNumbers(l1, l2, 0);
}
ListNode *addTwoNumbers(ListNode *l1, ListNode *l2, int carry) {
...
分类:
其他好文 时间:
2014-09-14 12:53:17
阅读次数:
216
题目:
The gray code is a binary numeral system where two successive values differ in only one bit.
Given a non-negative integer n representing the total number of bits in the code, print the...
分类:
其他好文 时间:
2014-09-14 11:22:47
阅读次数:
181
7.4Write methods to implement the multiply, subtract, and divide operations for integers. Use only the add operator.比较简单。但是要封装得好。7.5 Given two squares...
分类:
其他好文 时间:
2014-09-14 11:17:07
阅读次数:
189