- 博客(11)
- 资源 (4)
- 收藏
- 关注
原创 Binary Tree Preorder Traversal & Binary Tree Postorder Traversal
Preorder /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cl
2013-11-21 10:13:34 598
原创 Merge k Sorted Lists
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *me
2013-11-21 10:04:52 540
原创 Sort
Wiki link http://en.wikipedia.org/wiki/Sorting_algorithm 1. Bubble Sort : O(n^2) for array 两层for循环,交换相邻元素。 2. Selection Sort : O(n^2) for array 两层for循环,每次找到最小值放在对应的位置,交换。 3. Insertion S
2013-11-20 15:43:41 658
原创 Divide Two Integers
A failure is the case (-2147483648, -2147483648). Here the problem is about the boundary of integer. For int (32 bits): [-2147483648, 2147483647] unsigned int [0, 4294967295] long (32bits) same
2013-11-20 10:16:40 573
原创 Remove Nth Node From End of List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *re
2013-11-14 16:30:59 343
原创 Insertion Sort List
Insertion sort /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public:
2013-11-14 14:28:30 426
原创 Flatten Binary Tree to Linked List
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Soluti
2013-11-13 02:17:38 310
原创 Linked List Cycle
I: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: bool h
2013-11-12 06:03:30 425
原创 Reorder List
O(n) complexity and O(1) space A linked list reverse function included. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x)
2013-11-12 03:09:39 406
原创 MATLAB 数据处理
1,均值:mean(A) 2,标准差:std(data(:),flag) flag=0, 无偏标准差 3,排序:[a, b] = sort(data) 4,求出现频率: x=data(:) x=sort(x); d=diff([x;max(x)+1]); count = diff(find([1;d])) ; y =[x(find(d)) count] 最后输出的y(1)
2013-11-05 15:50:00 831
原创 waitpid
等待所有子进程结束: pid_t pr; do { pr = waitpid(0, NULL, WNOHANG); printf("pid %d\n",pr); if (pr==0) { printf("I'm the father process, the child p
2013-11-01 15:01:28 395
Cracking the Coding Interview
2013-01-17
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人