上一页 1 ··· 3 4 5 6 7 8 9 10 下一页
摘要: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Exampl... 阅读全文
posted @ 2015-10-17 11:31 dylqt 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 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 / \ ... 阅读全文
posted @ 2015-10-16 14:58 dylqt 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 一、基本概念1、重载运算符是具有特殊名字的函数:由关键字operator和其他要定义的运算符号共同组成2、重载运算符的参数数量与该运算符作用的运算对象一样多当一个重载的运算符是成员函数时,this会绑定到左侧运算对象,成员运算符函数的显示参数数量比运算对象的数量少一个3、对于一个运算符函数,它要么是... 阅读全文
posted @ 2015-10-16 12:28 dylqt 阅读(228) 评论(0) 推荐(0) 编辑
摘要: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of... 阅读全文
posted @ 2015-10-16 09:30 dylqt 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between t... 阅读全文
posted @ 2015-10-15 20:15 dylqt 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following is ... 阅读全文
posted @ 2015-10-15 16:06 dylqt 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1 /** * Definition for a binary tree node. * struct TreeNode { * int val; ... 阅读全文
posted @ 2015-10-15 08:51 dylqt 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 一、拷贝控制操作 1、拷贝构造函数:一个构造函数的一个参数是自身类类型的引用,且额外参数都有默认值 class Foo{ public: Foo(const Foo&); //拷贝构造函数;必须引用类型;最好是const类型;不应该是explicit的 } 拷贝构造函数通常会被隐式使用,所以不应该是explicit 如果我们没有为一个类定义拷贝构造函数,编译器会定义一个... 阅读全文
posted @ 2015-10-14 22:17 dylqt 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are:["1->2->5", "1->3"] /** * Definition for a bin... 阅读全文
posted @ 2015-10-12 18:28 dylqt 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. /** * Definition for a binary tree node... 阅读全文
posted @ 2015-10-12 10:20 dylqt 阅读(191) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页