c++
文章平均质量分 91
dream or nightmare
分享资源,总结知识,一起进步。
展开
-
LeetCode每日一题10.29-11.9
class Solution {public: bool isSelfCrossing(vector<int>& distance) { int n = distance.size(); if(n <= 3) return false; for(int i = 3; i < n; i++) { if(distance[i] >= distance[i-2] && dist.原创 2021-10-29 14:20:46 · 493 阅读 · 0 评论 -
第四章 入门篇(2) 算法初步
1012 The Best Rank (25 分)To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE- English. At the mean time, we en...原创 2021-08-20 09:48:15 · 775 阅读 · 0 评论 -
算法笔记 第六章第七章第八章
第六章 标准模板库A1039. Course List for StudentA1047. Student List for Course使用map会超时#include <iostream>#include <vector>#include <algorithm>#include <string.h>using namespace std;char name[40010][5];vector<int> co.原创 2021-08-20 09:43:01 · 582 阅读 · 0 评论 -
算法笔记.胡凡 第11章 动态规划专题
11.1 动态规划的递归写法和递推写法11.1.1 动态规划的递归写法以斐波那契数列为例,递归代码为int F(int n) { if (n == 0 || n == 1) return 1; else return F(n-1) + F(n-2);}这个递归涉及太多的重复计算,为了避免重复计算,可以开一个一维数组dp,用来保存已经计算过的结果。dp[n] = -1表示F(n)当前还没有被计算过。int dp[MAXV];int F(int n) { if原创 2021-08-16 10:37:10 · 332 阅读 · 0 评论 -
算法笔记.胡凡 第九章 二叉树
9.1 树与二叉树二叉树的存储struct node { typename data; node* lchild; node* rchild;};新建节点node* newNode(int v) { node* Node = new node; Node->data = v; Node->lchild = Node->rchild = NULL; return Node;}二叉树的查找void sea原创 2021-08-13 14:49:36 · 282 阅读 · 0 评论 -
算法笔记.胡凡 第七章 数据结构专题 & 第八章 搜索专题
7.3 链表处理7.3.1 链表概念struct node { typename data;//数据域 node* next;//指针域};链表可以分为带头结点的和不带头结点的链表。7.3.2 为链表节点分配内存空间1. malloc函数typename* p = (typename*) malloc(sizeof(typename));int* p = (int*) malloc(sizeof(int));int* p = (int*) malloc(10原创 2021-08-12 09:30:04 · 227 阅读 · 0 评论 -
C++ STL常用算法
目录1. 常用遍历算法1.1 for_each遍历容器1.2 transorm 搬运容器到另一个容器中2. 常用查找算法2.1 find查找算法2.2 find_if条件查询2.3 adjacent_find 查找相邻重复元素.2.4 binary_search 二分查找2.5 count 统计元素个数2.6 count_if 条件统计3.排序算法3.1 sort对容器元素排序3.2 random_shuffle 随机调整顺序3.3 merge容器元.转载 2021-07-22 17:07:38 · 473 阅读 · 0 评论 -
C++ STL
1. STL介绍1.1 STL基本概念STL即standard template library的缩写,标准模板库。主要是提升常用函数和数据结构的复用性。STL从广义上分为:容器、算法、迭代器容器和算法之间通过迭代器无缝连接。1.2 STL六大组件STL大体上分为六大组件:容器、算法、迭代器、仿函数、适配器、空间配置器容器:各种数据结构,如vector、list、deque、set、map等,用来存放数据。 算法:各种常用的算法,如sort、find、copy、for_each转载 2021-07-22 14:32:03 · 237 阅读 · 0 评论