摘要:
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.For example,Consider the following matrix:[ [1, .. 阅读全文
posted @ 2013-07-26 18:57
冰点猎手
阅读(260)
评论(0)
推荐(0)
摘要:
Implement atoi to convert a string to an integer.int atoi (const char * str);Convert string to integerParses the C-string str interpreting its content as an integral number, which is returned as a value of type int.The function first discards as many whitespace characters (as in isspace) as necessar 阅读全文
posted @ 2013-07-26 16:34
冰点猎手
阅读(247)
评论(0)
推荐(0)
摘要:
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val 阅读全文
posted @ 2013-07-26 13:37
冰点猎手
阅读(171)
评论(0)
推荐(0)
摘要:
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321class Solution {public: int reverse(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function if(x == 0) return x; int flag = 1; if(x r... 阅读全文
posted @ 2013-07-26 11:23
冰点猎手
阅读(129)
评论(0)
推荐(0)
摘要:
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,If S = [1,2,2], a solution is: [ [2], [1], [1,2,2], [2,2], [1,2], []]DFS :clas... 阅读全文
posted @ 2013-07-26 10:43
冰点猎手
阅读(226)
评论(0)
推荐(0)
摘要:
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 must not contain duplicate subsets.For example,If S = [1,2,3], a solution is:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []] DFS 的简单应用 : 求组合class So... 阅读全文
posted @ 2013-07-26 10:17
冰点猎手
阅读(255)
评论(0)
推荐(0)