LeetCode

A collection of 2 posts

[LeetCode] 65. Valid Number

class Solution { public: bool isNumber(string s) { const char *p = s.c_str(), *q; // trim left while (std::isspace(*p)) ++p; if (*p == '+' || *p == '-') ++p; q = p; while (std::isdigit(

[LeetCode] 814. Binary Tree Pruning

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* pruneTree(TreeNode* root) { if (root->