题意:给出一个区间的集合,请合并所有重叠的区间。 https://leetcode-cn.com/problems/merge-intervals/ 解题思路一:使用排序,开始时间从小至大排序。 1 vector<vector<int>> merge(vector<vector<int>>& int ...
分类:
其他好文 时间:
2020-01-26 13:00:39
阅读次数:
77
因为最大可以达到int极限 明显直接筛选不可能完成 所以从其因子入手 因为任何不是素数的数都有除了1与其自身之外的因子 因此,我们筛出2^(31/2)≈46350之内的所有素数,以其作为因子再将题目给定区间内的所有不是素数的数标记排除 然后将素数存放在prnum这个vector集合中便于调用 在排除 ...
分类:
其他好文 时间:
2020-01-26 10:26:11
阅读次数:
75
Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, a ...
分类:
其他好文 时间:
2020-01-25 15:29:55
阅读次数:
87
c++中标准库中有很多自由方法,比如swap,copy,从这个方面入手深入学习c++。 int casts[10] = {10,21,21,12,121,2,1,12,290,12}; vector<int> vect(10); copy(casts,casts+10,vect.begin()); ...
分类:
编程语言 时间:
2020-01-24 23:48:41
阅读次数:
152
#include <cstdio> #include <iostream> #include <vector> #include <string> using namespace std; typedef struct student { int no; string name; string se ...
分类:
其他好文 时间:
2020-01-24 13:22:19
阅读次数:
81
概要 JDK中提供ArrayList集合方便我们对集合内元素进行增删改查,但是ArrayList为了能够在单线程中快速进行操作其设计并不支持多线程进行操作。ArrayList在多线程环境下可能会产生java.util.ConcurrentModificationException异常。而对于我们需要 ...
分类:
编程语言 时间:
2020-01-24 09:17:58
阅读次数:
81
1. 数组的大小声明符必须是一个常数或常量表达式。如果省略大小声明符,则必须提供一个初始化列表。 2. 如果数组被部分初始化,那么其余部分会自动被设置为 0 。 3. 基于范围的 for 循环可用于需要遍历数组所有元素的情形。但是需要使用数组下标时,就不能使用了。 4. 复制数组时,必须对元素进行逐 ...
分类:
编程语言 时间:
2020-01-24 00:18:31
阅读次数:
83
基本思想: 没什么难的,水题,重点在于审题; 关键点: 无; #include<iostream> #include<stdlib.h> #include<stdio.h> #include<vector> #include<string> #include<math.h> #include<alg ...
分类:
其他好文 时间:
2020-01-23 12:39:56
阅读次数:
82
剑指OFFER 旋转数组的最小数字 暴力解法 直接一次扫描找出最小元素,时间效率比较低,需要改进 发现提交测试的时间还是一样的,可能是测评系统的问题吧,使用了二分查找多少都会快一些吧 ...
分类:
编程语言 时间:
2020-01-23 09:22:03
阅读次数:
58
#include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<algorithm> #include<cstring> #include<string> #include<vector> #include ...
分类:
其他好文 时间:
2020-01-23 00:23:21
阅读次数:
125