![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++学习记录
逐风的小黄
人生要不断保持进步,不进步就会哭T﹏T!
展开
-
C++ STL 序列式容器
C++ STL 序列式容器什么是序列式容器序列容器就是以线性序列方法来存储元素的容器,它对元素的顺序和存放顺序相关,具体的容器主要有5种。分别是:1、array<T,N> 数组容器,特点是长度固定,可以随机存取;2、vector< T > 向量容器,特点是长度不固定,可以自动扩容,一般在队尾进行元素的增删,可以随机存取;3、deque< T >双向队列...原创 2019-08-07 00:26:29 · 383 阅读 · 0 评论 -
leetcode之maximum-depth-of-binary-tree(求出二叉树的最大深度)
leetcode之maximum-depth-of-binary-tree(求出二叉树的最大深度)题目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 farthes...原创 2019-06-16 20:21:41 · 167 阅读 · 0 评论 -
leetcode之construct-binary-tree-from-preorder-and-inorder-traversal(给定先序遍历和中序遍历,还原整个二叉树)
leetcode之construct-binary-tree-from-preorder-and-inorder-traversal(给定先序遍历和中序遍历,还原整个二叉树)题目Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicat...原创 2019-06-16 19:32:13 · 419 阅读 · 0 评论 -
leetcode之validate-binary-search-tree(判断二叉树是否是BST搜索二叉树)
leetcode之validate-binary-search-tree(判断二叉树是否是BST搜索二叉树)题目Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node conta...原创 2019-06-19 22:40:03 · 486 阅读 · 0 评论 -
leetcode之pascals-triangle(杨辉三角-1)
leetcode之pascals-triangle(杨辉三角-1)题目Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5,Return题意给定一个index k,返回高度为k的杨辉三角矩阵。解题思路直接按照杨辉三角的来源规则来就好,从上往下依次计...原创 2019-06-03 23:14:56 · 152 阅读 · 1 评论 -
leetcode之pascals-triangle-ii(杨辉三角)
leetcode之pascals-triangle-ii(杨辉三角)题目Given an index k, return the k th row of the Pascal’s triangle.For example, given k = 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use only O(k...原创 2019-06-03 22:19:40 · 140 阅读 · 0 评论 -
leetcode之pascals-triangle-ii(杨辉三角)
leetcode之pascals-triangle-ii(杨辉三角)题目Given an index k, return the k th row of the Pascal’s triangle.For example, given k = 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use only O(k...原创 2019-06-03 22:19:08 · 124 阅读 · 0 评论 -
leetcode之recover-binary-search-tree(搜索二叉树BST重建)
leetcode之recover-binary-search-tree(搜索二叉树BST重建)题目Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n ) spac...原创 2019-06-19 21:06:55 · 432 阅读 · 0 评论 -
leetcode之binary-tree-level-order-traversal-ii(二叉树按照层次转化为二维数组)
leetcode之binary-tree-level-order-traversal-ii(二叉树按照层次转化为二维数组)题目Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf...原创 2019-06-09 20:11:36 · 424 阅读 · 0 评论 -
leetcode之triangle(动态规划)
leetcode之triangle(动态规划)题目Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[[2],...原创 2019-06-02 20:10:54 · 232 阅读 · 0 评论 -
leetcode之convert-sorted-array-to-binary-search-tree(将递增数组转化为BST搜索二叉树)
leetcode之convert-sorted-array-to-binary-search-tree(将递增数组转化为BST搜索二叉树)题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题意给定一个递增的连续数组,将其转化为一个BST搜索二叉...原创 2019-06-07 11:20:48 · 202 阅读 · 0 评论 -
leetcode之convert-sorted-list-to-binary-search-tree(将一个递增链表转化为一个搜索二叉树)
leetcode之convert-sorted-list-to-binary-search-tree(将一个递增链表转化为一个搜索二叉树)题目Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题意给定一个递增的链表,然后将这...原创 2019-06-07 10:56:48 · 165 阅读 · 0 评论 -
leetcode之balanced-binary-tree(平衡二叉树判断)
leetcode之balanced-binary-tree(平衡二叉树判断)题目Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...原创 2019-06-07 00:33:21 · 143 阅读 · 0 评论 -
进程状态及转换
进程状态及转换进程状态对进程可以执行有很多种状态,可以创建和销毁,也可以更改优先权,进程状态是进程某时某刻所处的模式或条件。进程的状态也决定了将来的事件以及可能进入的状态。其中、准备执行的进程处于就绪状态。如果某个进程因为等待某个资源或者事件的发送而不能执行,则进入阻塞状态。就绪和阻塞状态是最常见的进程状态之一。只有位于就绪队列内的进程才有资格使用处理器,获得CPU,会按照一定的序列从...原创 2019-06-17 00:48:07 · 1630 阅读 · 0 评论 -
C++8种常见类类型
C++8种常见类类型前言大部分面向对象开发工作中都应用了以下部分或者全部的基本类别的类:1、具体类(concrete class)2、抽象类(abstract class)3、接口类(interface class)4、节点类(node class)5、支持类(support class)6、域类(domain class)7、应用类(utility class)8、集合和容器...原创 2019-06-11 21:59:24 · 11560 阅读 · 0 评论 -
leetcode之construct-binary-tree-from-inorder-and-postorder-traversal(给定中序遍历和后序遍历,还原二叉树)
leetcode之construct-binary-tree-from-inorder-and-postorder-traversal(给定中序遍历和后序遍历,还原二叉树)题目Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicat...原创 2019-06-12 00:03:22 · 208 阅读 · 0 评论 -
C++ STL string类
C++ STL string类String简介STL 中只有一个字符串类,即 basic_string,实现管理以’\0’结尾的字符数组,字符类型由模板参数决定。字符类型的性质是由字符特征类(char_traits)定义的:template <class Ch> struct char_traits { }string 作为类出现,其集成的操作函数足以完成多数情况下的需要。...原创 2019-08-02 00:54:48 · 368 阅读 · 0 评论 -
C++ STL String类(2)
C++ STL String类(2)string内容的修改一般来说 有很多种方法可以去修改string,例如assign(),operator=,erase(),swap(),insert(),append()等等;assign这个函数可以直接给string再重新赋值,例如:#include <iostream>#include <string>using n...原创 2019-08-04 23:37:07 · 402 阅读 · 0 评论 -
C++进程资源
C++进程资源什么是资源资源时进程执行任务过程中所使用的硬件设备或者软件材料,资源包括硬盘、RAM、CPU、打印机、显示器、键盘、网卡、文件、程序、数据、动态链接库等等。资源可以是进程在任何给定时间使用的任何东西。硬件资源硬件资源是物理设备,例如CPU,进程使用它来进行数据操纵计算执行等等。此外还有内存RAM、外存ROM、非抢占式打印机、屏幕键盘鼠标等I/O设备。这些I/O资源可以被多...原创 2019-07-01 00:19:16 · 2770 阅读 · 0 评论 -
C++进程映射
C++进程映射进程片段进程有3个片段,分别是文本片段、堆栈片段、数据片段。进程的地址空间布局是既有物理模型,也有逻辑模型。物理模型是关于具体的真实的资源是怎么一一存放在RAM上的。逻辑模型是一块虚拟出来的内存管理,其在布局的底端有文本片段,接着是数据片段,最后是堆栈片段。逻辑布局使用的是虚拟地址空间,它是一套进程可用可见的一个虚拟地址,映射到具体真实的物理地址上去。而片段又会被分解成...原创 2019-07-01 00:05:32 · 369 阅读 · 0 评论 -
leetcode之restore-ip-addresses(找出所有字符串中符合条件的IP网址,并返回)
leetcode之restore-ip-addresses(找出所有字符串中符合条件的IP网址,并返回)题目Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",retu...原创 2019-06-30 23:09:02 · 366 阅读 · 0 评论 -
leetcode之binary-tree-inorder-traversal(二叉树中序遍历)
leetcode之binary-tree-inorder-traversal(二叉树中序遍历)题目Given a binary tree, return the inorder traversal of its nodes’ values.For example:Given binary tree{1,#,2,3},return[1,3,2].Note: Recursive solu...原创 2019-06-23 23:50:50 · 943 阅读 · 0 评论 -
leetcode之unique-binary-search-trees-ii(求出1-n数组可以组成的所有BST二叉树)
leetcode之unique-binary-search-trees-ii(求出1-n数组可以组成的所有BST二叉树)题目Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example,Given n = 3, your program shou...原创 2019-06-23 23:32:31 · 325 阅读 · 0 评论 -
leetcode之unique-binary-search-trees(求长度为n的BST有多少个)
leetcode之unique-binary-search-trees(求长度为n的BST有多少个)题目Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example,Given n = 3, there are a total of 5 unique B...原创 2019-06-23 23:00:17 · 164 阅读 · 0 评论 -
leetcode之same-tree(判断两个二叉树是否相等)
leetcode之same-tree(判断两个二叉树是否相等)题目Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes ha...原创 2019-06-18 01:35:29 · 517 阅读 · 0 评论 -
leetcode之symmetric-tree(判断二叉树是否是镜像二叉树)
leetcode之symmetric-tree(判断二叉树是否是镜像二叉树)题目Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric:But the following ...原创 2019-06-18 01:30:39 · 1094 阅读 · 0 评论 -
leetcode之binary-tree-level-order-traversal(二叉树层次遍历输出)
leetcode之binary-tree-level-order-traversal(二叉树层次遍历输出)题目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...原创 2019-06-18 01:17:37 · 172 阅读 · 0 评论 -
leetcode之binary-tree-zigzag-level-order-traversal
leetcode之binary-tree-zigzag-level-order-traversal题目Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level a...原创 2019-06-18 01:09:49 · 179 阅读 · 0 评论 -
leetcode之path-sum
leetcode之path-sum题目Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below b...原创 2019-06-06 21:53:37 · 139 阅读 · 0 评论 -
C++什么是进程?进程由什么组成?
C++什么是进程?进程由什么组成?什么是进程进程就是执行中的一段程序,一旦程序被装载到了内存中并准备执行时,它就是一个进程。进程的组成进程具备文本、数据和堆栈片段以及它自己的资源。其中资源可以是文件、对象句柄、设备、信号量、互斥量、管道等等。操作系统中有大量的信息和进程息息相关。这些信息保存在一个叫做进程控制块、或者进程信息块的结构里面。这个结构就是进程对操作系统的表现形式。重要信息定义...原创 2019-06-12 21:37:08 · 2239 阅读 · 0 评论 -
leetcode之path-sum-ii(求所有和为固定值的二叉树路径)
leetcode之path-sum-ii(求所有和为固定值的二叉树路径)题目Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example:Given the below binary tree andsum = 22,re...原创 2019-06-05 23:01:14 · 343 阅读 · 0 评论 -
leetcode之word-break(动态规划)
题目Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens =“leetcode”,dict =[“leet”, “c...原创 2019-04-27 00:08:02 · 306 阅读 · 0 评论 -
C++多态
C++多态多态按字面的意思就是多种形态。当类之间存在层次结构,并且类之间是通过继承关联时,就会用到多态。C++ 多态意味着调用成员函数时,会根据调用函数的对象的类型来执行不同的函数。静态链接(静态多态)函数调用在程序执行前就准备好了。有时候这也被称为早绑定。#include <iostream> using namespace std; class Shape { ...原创 2019-04-12 20:03:04 · 225 阅读 · 0 评论 -
C++继承和重载
C++继承和重载c++集成继承允许我们依据另一个类来定义一个类,这使得创建和维护一个应用程序变得更容易。这样做,也达到了重用代码功能和提高执行时间的效果。当创建一个类时,您不需要重新编写新的数据成员和成员函数,只需指定新建的类继承了一个已有的类的成员即可。这个已有的类称为基类,新建的类称为派生类。一个类可以派生自多个类,这意味着,它可以从多个基类继承数据和函数。定义一个派生类,我们使用一个...原创 2019-04-12 19:49:37 · 6214 阅读 · 2 评论 -
C++类静态成员和静态函数
C++类静态成员和静态函数我们可以使用 static 关键字来把类成员定义为静态的。静态成员变量当我们声明类的成员为静态时,这意味着无论创建多少个类的对象,静态成员都只有一个副本。静态成员在类的所有对象中是共享的。如果不存在其他的初始化语句,在创建第一个对象时,所有的静态数据都会被初始化为零。我们不能把静态成员的初始化放置在类的定义中,但是可以在类的外部通过使用范围解析运算符 :: 来重新...原创 2019-04-12 19:12:47 · 244 阅读 · 0 评论 -
C/C++类&对象
C/C++类&对象C++ 在 C 语言的基础上增加了面向对象编程,C++ 支持面向对象程序设计。类是 C++ 的核心特性,通常被称为用户定义的类型。类用于指定对象的形式,它包含了数据表示法和用于处理数据的方法。类中的数据和方法称为类的成员。函数在一个类中被称为类的成员。类成员函数类的成员函数是指那些把定义和原型写在类定义内部的函数,就像类定义中的其他变量一样。类成员函数是类的一个成...原创 2019-04-12 19:06:48 · 150 阅读 · 0 评论 -
leetcode之minimum-depth-of-binary-tree
minimum-depth-of-binary-treequestionGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.给定二...原创 2019-04-08 22:27:57 · 134 阅读 · 0 评论 -
C++引用
C++引用引用变量是一个别名,也就是说,它是某个已存在变量的另一个名字。一旦把引用初始化为某个变量,就可以使用该引用名称或变量名称来指向变量。C++引用VS指针引用很容易与指针混淆,它们之间有三个主要的不同:1.不存在空引用。引用必须连接到一块合法的内存。2.一旦引用被初始化为一个对象,就不能被指向到另一个对象。指针可以在任何时候指向到另一个对象。3.引用必须在创建时被初始化。指针可以...原创 2019-04-10 21:09:32 · 226 阅读 · 0 评论 -
C++函数传递和返回数组
C++函数传递和返回数组C++函数传递数组C++ 中您可以通过指定不带索引的数组名来传递一个指向数组的指针。C++ 传数组给一个函数,数组类型自动转换为指针类型,因而传的实际是地址。如果您想要在函数中传递一个一维数组作为参数,您必须以下面三种方式来声明函数形式参数,这三种声明方式的结果是一样的,因为每种方式都会告诉编译器将要接收一个整型指针。同样地,您也可以传递一个多维数组作为形式参数。...原创 2019-04-10 20:46:23 · 1029 阅读 · 0 评论 -
C/C++三种函数入参方法
C/C++三种函数入参方法函数是一组一起执行一个任务的语句。每个 C++ 程序都至少有一个函数,即主函数 main() ,所有简单的程序都可以定义其他额外的函数。您可以把代码划分到不同的函数中。如何划分代码到不同的函数中是由您来决定的,但在逻辑上,划分通常是根据每个函数执行一个特定的任务来进行的。函数声明告诉编译器函数的名称、返回类型和参数。函数定义提供了函数的实际主体。C++ 标准库提供...原创 2019-04-10 20:30:10 · 6254 阅读 · 0 评论