当前位置:网站首页>Leetcode problem solving 2.1.1
Leetcode problem solving 2.1.1
2022-07-06 09:04:00 【Long time no see 0327】
distance() The function is used to calculate the number of elements in the range represented by two iterators
template<class Inputlterator>
typename iterator_traits<Inputlterator>::difference_type distance(Inputlterator first, Inputlterator last);#include<iostream>
#include<iterator>
#include<list>
using namespace std;
int main() {
// Create an empty list Containers
list<int> mylist;
// Empty list Add elements to the container 0~9
for (int i = 0; i < 10; i++) {
mylist.push_back(i);
}
// Appoint 2 Two way iterators , Used to execute a certain interval
list<int>::iterator first = mylist.begin(); // Point to elements 0
list<int>::iterator last = mylist.end(); // Point to elements 9 The position after
// obtain [first, last) Number of elements in the range
cout << "distance() = " << distance(first, last);
return 0;
}unique The function of the function is to remove duplicate elements . namely “ Delete ” All adjacent repeating elements in the sequence ( Keep only one )
边栏推荐
- LeetCode:剑指 Offer 04. 二维数组中的查找
- Philosophical enlightenment from single point to distributed
- [text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
- Navicat premium create MySQL create stored procedure
- ant-design的走马灯(Carousel)组件在TS(typescript)环境中调用prev以及next方法
- Simclr: comparative learning in NLP
- IJCAI2022论文合集(持续更新中)
- Tdengine biweekly selection of community issues | phase III
- LeetCode:387. 字符串中的第一个唯一字符
- Promise 在uniapp的简单使用
猜你喜欢

Intel Distiller工具包-量化实现3
![[OC foundation framework] - [set array]](/img/b5/5e49ab9d026c60816f90f0c47b2ad8.png)
[OC foundation framework] - [set array]

LeetCode41——First Missing Positive——hashing in place & swap

KDD 2022 paper collection (under continuous update)

数学建模2004B题(输电问题)

【嵌入式】使用JLINK RTT打印log

Mongodb installation and basic operation

Pytest之收集用例规则与运行指定用例

vb. Net changes with the window, scales the size of the control and maintains its relative position

requests的深入刨析及封装调用
随机推荐
LeetCode:673. Number of longest increasing subsequences
Revit secondary development Hof method calls transaction
[OC]-<UI入门>--常用控件-UIButton
【shell脚本】——归档文件脚本
LeetCode:221. Largest Square
BN折叠及其量化
ant-design的走马灯(Carousel)组件在TS(typescript)环境中调用prev以及next方法
Navicat Premium 创建MySql 创建存储过程
SAP ui5 date type sap ui. model. type. Analysis of the parsing format of date
使用latex导出IEEE文献格式
【剑指offer】序列化二叉树
Variable length parameter
Advanced Computer Network Review(3)——BBR
[OC-Foundation框架]--<Copy对象复制>
LeetCode:498. Diagonal traversal
CUDA实现focal_loss
AcWing 2456. 记事本
什么是MySQL?MySql的学习之路是怎样的
【嵌入式】使用JLINK RTT打印log
Niuke winter vacation training 6 maze 2