摘要: 并归排序的思想,新get一种地址取法~之前怎么想不到。。 1 #include 2 #include 3 using namespace std; 4 5 class Solution { 6 public: 7 void merge(int A[], int m, int B[], int n) { 8 if(n == 0) return ; 9 if(m == 0){10 memcpy(A,B,sizeof(int)*n);11 return ;12 }13 int... 阅读全文
posted @ 2014-03-18 21:25 青轰的后花园 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 递归的思想,左子树整理成一条链,右子树整理成一条链,然后左子树的尾节点链上右子树的头节点就好了 1 #include 2 using namespace std; 3 struct TreeNode { 4 int val; 5 TreeNode *left; 6 TreeNode *right; 7 TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 }; 9 class Solution {10 public:11 void flatten(TreeNode *root) {12 ... 阅读全文
posted @ 2014-03-18 17:03 青轰的后花园 阅读(135) 评论(0) 推荐(0) 编辑