当前位置:网站首页>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 )
边栏推荐
- UML图记忆技巧
- MongoDB 的安装和基本操作
- LeetCode:498. 对角线遍历
- 【嵌入式】Cortex M4F DSP库
- Leetcode刷题题解2.1.1
- Intel distiller Toolkit - Quantitative implementation 2
- Show slave status \ read in G_ Master_ Log_ POS and relay_ Log_ The (size) relationship of POS
- AcWing 2456. 记事本
- [OC]-<UI入门>--常用控件的学习
- [today in history] February 13: the father of transistors was born The 20th anniversary of net; Agile software development manifesto was born
猜你喜欢
Alibaba cloud server mining virus solution (practiced)
LeetCode:124. Maximum path sum in binary tree
Compétences en mémoire des graphiques UML
注意力机制的一种卷积替代方式
IJCAI2022论文合集(持续更新中)
Pytest参数化你不知道的一些使用技巧 /你不知道的pytest
Chapter 1 :Application of Artificial intelligence in Drug Design:Opportunity and Challenges
requests的深入刨析及封装调用
TP-LINK 企业路由器 PPTP 配置
[embedded] cortex m4f DSP Library
随机推荐
Selenium+pytest automated test framework practice
TP-LINK enterprise router PPTP configuration
Mise en œuvre de la quantification post - formation du bminf
Improved deep embedded clustering with local structure preservation (Idec)
Pytest参数化你不知道的一些使用技巧 /你不知道的pytest
Simple use of promise in uniapp
[oc]- < getting started with UI> -- learning common controls
Philosophical enlightenment from single point to distributed
Selenium+Pytest自动化测试框架实战
Intel distiller Toolkit - Quantitative implementation 3
[text generation] recommended in the collection of papers - Stanford researchers introduce time control methods to make long text generation more smooth
TP-LINK 企业路由器 PPTP 配置
Advanced Computer Network Review(5)——COPE
LeetCode:836. Rectangle overlap
数字人主播618手语带货,便捷2780万名听障人士
LeetCode:498. 对角线遍历
Navicat premium create MySQL create stored procedure
Esp8266-rtos IOT development
LeetCode:劍指 Offer 42. 連續子數組的最大和
LeetCode:124. 二叉树中的最大路径和