摘要: 关于lambda的捕获和调用 C++ primer上对可变lambda举的例子如下: 因为原则上不能改变值捕获的v1,所以要在lambda里改变v1的话,需要加上mutable关键字。 我一开始不理解为什么j为43,而不是1。说明捕获是发生在 这句。而函数体内部语句调用,是在调用f()的时候执行。 阅读全文
posted @ 2019-10-10 17:21 HaoPeng_Zhang 阅读(1069) 评论(0) 推荐(1) 编辑
摘要: 题目描述 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where " 阅读全文
posted @ 2019-09-25 20:47 HaoPeng_Zhang 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 剑指offer第8题,本来想找leetcode上对应的题,后来没找到,直接去牛客网上刷了。 题目描述: 给定一个二叉树和其中的一个结点(pNode),请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。 分析 我看到这道题的第一个想法,就是不用管左子 阅读全文
posted @ 2019-09-18 21:19 HaoPeng_Zhang 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 题目描述 Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For exa 阅读全文
posted @ 2019-09-18 17:41 HaoPeng_Zhang 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 最近在读C++ primer的时候,发现p32上写道:当我们赋给无符号类型一个超出它表示范围的值时,结果是初始值对无符号类型表示数值总数取模后的余数。因此,把 1赋值给8比特大小的unsigned char所得的结果是255。 1怎么取模?   这里先明确一下取模和取余的区别:( 阅读全文
posted @ 2019-09-18 15:18 HaoPeng_Zhang 阅读(1330) 评论(0) 推荐(0) 编辑
摘要: 题目描述如下 Reverse a singly linked list. Example: Input: 1 2 3 4 5 NULL Output: 5 4 3 2 1 NULL Follow up: A linked list can be reversed either iteratively 阅读全文
posted @ 2019-09-17 22:30 HaoPeng_Zhang 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 实现代码如下 include using namespace std; class Singleon{ private: Singleon(){ cout 阅读全文
posted @ 2019-09-15 10:18 HaoPeng_Zhang 阅读(833) 评论(0) 推荐(0) 编辑
摘要: 题目描述 Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output 阅读全文
posted @ 2019-09-01 21:10 HaoPeng_Zhang 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 题目描述 Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non 阅读全文
posted @ 2019-09-01 20:40 HaoPeng_Zhang 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 学习了扁扁熊的题解:https://leetcode cn.com/problems/median of two sorted arrays/solution/4 xun zhao liang ge you xu shu zu de zhong wei shu/ 记录一下,顺便按自己的理解给代码加上 阅读全文
posted @ 2019-08-28 22:30 HaoPeng_Zhang 阅读(136) 评论(0) 推荐(0) 编辑