There are generally two methods to write DFS
algorithm, one is using recursion, another one is using stack. (reference from
Wiki Pedia)Pseudocode for ...
分类:
其他好文 时间:
2014-06-13 08:39:34
阅读次数:
218
原题地址:https://oj.leetcode.com/problems/multiply-strings/题意:Given
two numbers represented as strings, return multiplication of the numbers as a
string.N...
分类:
编程语言 时间:
2014-06-12 21:43:03
阅读次数:
344
字典是无序的
数组是有序的。字典分为:可变字典和不可变字典不可变字典对象NSDictionary * dict = [[NSDictionary
alloc]initWithObjectsAndKeys:@"one",@"1",@"two",@"2",@"three",@"3",@"four",@"...
分类:
移动开发 时间:
2014-06-12 06:25:50
阅读次数:
324
Given two sorted integer arrays A and B, merge
B into A as one sorted array.Note:You may assume that A has enough space (size
that is greater or equal...
分类:
其他好文 时间:
2014-06-10 20:44:02
阅读次数:
298
Question: Mergeksorted linked lists and return
it as one sorted list. Analyze and describe its complexity.Solution: Find the
smallest list-head first....
分类:
其他好文 时间:
2014-06-10 19:51:30
阅读次数:
278
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...
分类:
其他好文 时间:
2014-06-10 19:38:39
阅读次数:
199
移除数组中重复次数超过2次以上出现的数,但是可以允许重复2次。
这个题类似Remove Duplicates from Sorted Array,第一个想法很直接就是计数,超过2次的就忽略,依据这个思路的代码见代码一;
上面的思路可行,但是代码看着比较冗余,判断比较多。再来想想原来的数组,该数组是排好序的,如果一个数出现3次以上,那么必有A[i] == A[i-2]。所以根据这个关系可以写出比较精简的代码二。详见代码。...
分类:
其他好文 时间:
2014-06-10 19:18:39
阅读次数:
250
题目
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first
two lists.
方法
有序链表,合并成一个有序链表。
public ListNod...
分类:
其他好文 时间:
2014-06-10 18:13:11
阅读次数:
241
题目
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
方法
从后往前,每个字符进行判断。
public String addBinary(String a, String...
分类:
其他好文 时间:
2014-06-10 17:50:48
阅读次数:
241