LeetCode Invert Binary Tree题目思路没什么思路可言;
真不敢相信他写不出;代码struct TreeNode* invertTree(struct TreeNode* root) {
if (root == NULL) return root;
invertTree(root->left);
invertTree(root->right);...
分类:
其他好文 时间:
2015-06-13 11:27:30
阅读次数:
234
LeetCode Rectangle Area题目思路刚开始自己写别提WA多少遍了;
后来看到标达真的被惊讶到了;
代码可以这么美;代码自己的#define min(A, B) (A > B ? B : A)bool pointInRectangle(int px, int py, int ax, int ay, int bx, int by) {
return ax <= px &&...
分类:
其他好文 时间:
2015-06-13 11:26:51
阅读次数:
276
Given a binary tree, return the postorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3}, 1
2
/
3return [3,2,1].Note: Recursive solution is trivial, could...
分类:
其他好文 时间:
2015-06-13 11:23:14
阅读次数:
113
Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example:
Given binary tree {3,9,20,#,#,15,7}, 3
/ 9 20
/ 1...
分类:
其他好文 时间:
2015-06-13 11:20:46
阅读次数:
114
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and hasN...
分类:
其他好文 时间:
2015-06-13 09:56:01
阅读次数:
100
$name) return $this->$name; return null; } public function connect($host,$user,$pass,$db,$charSet='utf8',$force=false) { if($this->db && ($this-...
分类:
数据库 时间:
2015-06-13 06:18:35
阅读次数:
229
程序的启动过程:main函数中执行了一个UIApplicationMain这个函数int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFrom...
分类:
移动开发 时间:
2015-06-13 06:18:28
阅读次数:
180
题目意思:x为double,n为int,求x的n次方思路分析:直接求,注意临界条件 1 class Solution { 2 public: 3 double myPow(double x, int n) { 4 if(x==1.0)return x; 5 e...
分类:
其他好文 时间:
2015-06-13 06:16:35
阅读次数:
121
Reverse digits of an integer.Example1: x = 123, return 321
Example2: x = -123, return -321取一个数的最后一位,用x % 10,取一个数的前n-1位(共n位),用x/10,每一次取的时候,都将上一次取的数乘以10,然后再加上末尾的数即可,代码如下:Code(C++)class Solution {
public...
分类:
其他好文 时间:
2015-06-12 23:55:44
阅读次数:
178
废话不多说,直接上代码#include #define swap(a,b){long temp=*a;*a=*b;*b=temp;}void Permutation(char* pStr, char* pBegin){ if(!pStr || !pBegin) return; ...
分类:
编程语言 时间:
2015-06-12 23:49:51
阅读次数:
184