上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 44 下一页
摘要: C++ N叉树的实现 参考:https://www.cnblogs.com/muxuan/p/ntree.html #include <iostream> #include <string> #include <vector> #include <queue> using namespace std 阅读全文
posted @ 2020-10-25 16:25 r1-12king 阅读(580) 评论(0) 推荐(0) 编辑
摘要: string 常用相关操作 求字符串的长度 string s = "asdf" s.size() s.length() int和string互相转换 #include <iostream> #include <sstream> #include <string> using namespace st 阅读全文
posted @ 2020-10-21 21:46 r1-12king 阅读(234) 评论(0) 推荐(0) 编辑
摘要: itertools.permutations() itertools.permutations(iterable, r=None) 连续返回由 iterable 元素生成长度为 r 的排列。 如果 r 未指定或为 None ,r 默认设置为 iterable 的长度,这种情况下,生成所有全长排列。 阅读全文
posted @ 2020-10-21 16:56 r1-12king 阅读(3211) 评论(0) 推荐(0) 编辑
摘要: 问题:排序链表 要求:对链表进行排序,要求 时间复杂度O(n logn) 空间复杂度常数级别 PS: 学习链表寻找中点的方法 解法一:归并排序的递归解法(空间复杂度不符合,递归栈使用空间) struct ListNode { int val; ListNode *next; ListNode() : 阅读全文
posted @ 2020-10-19 18:38 r1-12king 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Python collections.Counter用法详解 转载自:Python计数器collections.Counter用法详解 Counter 计数器,顾名思义就是用来计数的,最主要的作用就是计算“可迭代序列中”各个元素(element)的数量。具体用法参看如下,基本涵盖了主要用法。 使用前 阅读全文
posted @ 2020-10-15 17:06 r1-12king 阅读(3198) 评论(0) 推荐(0) 编辑
摘要: 关于 fill 和fill_n函数是C++ Primer第十二章泛型算法部分内容,并把它们称为生成和变异算法,也就是说这两个函数只能对输入范围内已存在的元素进行操作。如果试图对空容器进行fill_n操作,会导致严重的运行错误,所以在对元素进行写入操作时要检查目标的大小是否足以存储要写入的元素。 fi 阅读全文
posted @ 2020-10-15 16:16 r1-12king 阅读(706) 评论(0) 推荐(0) 编辑
摘要: 1、关于集合 #include <iostream> // std::cout #include <algorithm> // std::set_intersection, std::sort #include<set> #include<string> #include <iterator> us 阅读全文
posted @ 2020-10-15 15:25 r1-12king 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 快速排序 —— 左右指针法的原理: (1)设最右值为枢轴值 (2)从左往右扫描,发现大于枢轴值的就进行位置互换 (3)从右往左扫描,发现小于枢轴值的就进行位置互换 #include <iostream> #include <stdlib.h> using namespace std; /****** 阅读全文
posted @ 2020-10-14 15:14 r1-12king 阅读(738) 评论(0) 推荐(0) 编辑
摘要: 一、题目 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。 二、解答 说明: 1、下面代码都没有判断数组本身是否为空,需要自己判断 2、找到一个数以后,需要判断这个数字是否满足“出现次数超过一半”的条件,代码如下 bool CheckMoreThanHalf(vector<int>&n 阅读全文
posted @ 2020-10-02 16:22 r1-12king 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 实现插入和查询 #include <iostream> #include <string> #include <vector> #include <algorithm> #include <stdexcept> using namespace std; struct Node { bool isWo 阅读全文
posted @ 2020-09-19 10:42 r1-12king 阅读(228) 评论(0) 推荐(0) 编辑
上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 44 下一页