摘要: 我们可以将上述代码写的更加简洁一些,用两个哈希表,分别记录p的字符个数,和s中前p字符串长度的字符个数,然后比较,如果两者相同,则将0加入结果res中,然后开始遍历s中剩余的字符,每次右边加入一个新的字符,然后去掉左边的一个旧的字符,每次再比较两个哈希表是否相同即可,参见代码如下: 解法二: 下面这 阅读全文
posted @ 2018-02-17 22:27 Sherry_Yang 阅读(160) 评论(0) 推荐(0) 编辑
摘要: You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need t 阅读全文
posted @ 2018-02-17 20:18 Sherry_Yang 阅读(132) 评论(0) 推荐(0) 编辑
摘要: You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need t 阅读全文
posted @ 2018-02-17 20:17 Sherry_Yang 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 判断一棵树中是否包含另一棵子树(包含是,两棵树重合处的根节点之下的子节点都相等) 有两种方法: 方法二:递归写法 方法一:比较两个字符串 https://www.cnblogs.com/zfyouxi/p/4074592.html 介绍ostringstream. 阅读全文
posted @ 2018-02-17 16:41 Sherry_Yang 阅读(162) 评论(0) 推荐(0) 编辑