【078-Subsets(子集)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a set of distinct integers, nums, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.
The solu...
分类:
编程语言 时间:
2015-08-03 07:51:16
阅读次数:
190
快慢指针到底指向哪?这个问题对于刚接触这种技巧的人来说往往把握不好.下面将以单链表为例, 说一点我个人的理解.
1) 比较通用的写法
if (head == NULL || head->next == NULL)
return true;
ListNode *fast = head, *slow = head, *prev = NULL;
while (fas...
分类:
其他好文 时间:
2015-08-03 01:19:05
阅读次数:
171
Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
分类:
其他好文 时间:
2015-08-03 01:04:34
阅读次数:
104
/*
* 带头节点
*/
ListNode * reverse(ListNode *head) {
if (head == NULL || head->next == NULL)
return head;
ListNode nhead(-1);//头节点
nhead.next = head;
ListNode *prev = head;
ListNode *n...
分类:
其他好文 时间:
2015-08-02 23:29:04
阅读次数:
225
1. 问题引入:开两个线程同时对一个全局变量10万次做自加,结果会如何?
#include
#include
#include
unsigned int g_cn = 0;
void* thread_proc (void* arg) {
unsigned int i;
for (i = 0; i < 100000; i++)
++g_cn;
return NULL;
}
...
分类:
编程语言 时间:
2015-08-02 23:27:26
阅读次数:
165
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
For example,
Given [3,2,1,5,6,4] and k = 2, return 5....
分类:
其他好文 时间:
2015-08-02 23:25:40
阅读次数:
111
User: model ; users: 表名; user_id键值 relation: public function tasks(){return $this->belongsToMany('Task','task_id');} Task: model名; tasks:表名; task_...
分类:
其他好文 时间:
2015-08-02 23:11:19
阅读次数:
134
Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur...
分类:
其他好文 时间:
2015-08-02 23:06:00
阅读次数:
208
OI生涯中印象最深一题 一直被卡0。。 1 #include 2 #define clr(a,x) memset(a,x,sizeof(a)) 3 #define rep(i,l,r) for(int i=l;is; 29 if(k==1) return -1; 30 ...
分类:
其他好文 时间:
2015-08-02 23:04:47
阅读次数:
142
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons...
分类:
其他好文 时间:
2015-08-02 21:42:27
阅读次数:
97