
剑指offer
海马HiMark
这个作者很懒,什么都没留下…
展开
-
剑指offer 二叉树的镜像
操作给定的二叉树,将其变换为源二叉树的镜像。 //二叉树的镜像 struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; }; class Solution { public: void Mirror(TreeNode *pRoot) { if (pRoot == nullptr) re...原创 2018-12-08 09:56:02 · 167 阅读 · 0 评论 -
剑指offer 树的子结构
输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构) class Solution { public: bool Hassubtree(TreeNode* root1, TreeNode* root2) { if (root1 == nullptr || root2 == nullptr) //约定树2不为空 return false; /...原创 2018-12-08 15:28:09 · 138 阅读 · 0 评论 -
剑指offer,面试题1,面试题2
面试题1:赋值运算符函数 面试题2:实现Singleton模式 赋值运算符函数 //TEST 1赋值运算符重载 class String { public: String(const char* pst =nullptr); String(const String& pst); ~String(); private: char * _pst; }; //赋值运算符重载,释放旧空...原创 2019-01-27 14:32:01 · 753 阅读 · 0 评论