当前位置:网站首页>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 )
边栏推荐
- [embedded] print log using JLINK RTT
- [OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
- Cesium draw points, lines, and faces
- TDengine 社区问题双周精选 | 第三期
- 数字人主播618手语带货,便捷2780万名听障人士
- 使用latex导出IEEE文献格式
- Selenium+pytest automated test framework practice
- Navicat premium create MySQL create stored procedure
- KDD 2022 paper collection (under continuous update)
- 【剑指offer】序列化二叉树
猜你喜欢

Advanced Computer Network Review(4)——Congestion Control of MPTCP

I-BERT

MYSQL卸载方法与安装方法

SimCLR:NLP中的对比学习

什么是MySQL?MySql的学习之路是怎样的

BN folding and its quantification

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

Detailed explanation of dynamic planning

Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment

Problems encountered in connecting the database of the project and their solutions
随机推荐
What is MySQL? What is the learning path of MySQL
Chapter 1 :Application of Artificial intelligence in Drug Design:Opportunity and Challenges
[OC]-<UI入门>--常用控件-UIButton
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Nacos 的安装与服务的注册
一篇文章带你了解-selenium工作原理详解
LeetCode:236. The nearest common ancestor of binary tree
requests的深入刨析及封装调用
什么是MySQL?MySql的学习之路是怎样的
LeetCode:162. 寻找峰值
[today in history] February 13: the father of transistors was born The 20th anniversary of net; Agile software development manifesto was born
[MySQL] limit implements paging
A convolution substitution of attention mechanism
LeetCode:26. Remove duplicates from an ordered array
Improved deep embedded clustering with local structure preservation (Idec)
Mise en œuvre de la quantification post - formation du bminf
Leetcode: Jianzhi offer 04 Search in two-dimensional array
甘肃旅游产品预订增四倍:“绿马”走红,甘肃博物馆周边民宿一房难求
LeetCode:剑指 Offer 42. 连续子数组的最大和
【每日一题】搬运工 (DFS / DP)