当前位置:网站首页>1041 be unique (20 points (s)) (hash: find the first number that occurs once)
1041 be unique (20 points (s)) (hash: find the first number that occurs once)
2022-07-06 12:33:00 【Vigorous waist Nuo dance】
title
Ideas
Two things are needed : One is a table that records the sequence , One is a table that records the number of times
Code
#include <iostream>
using namespace std;
int hashtable[100100], num[100100];
#define rep(i,j,k) for(int i=j;i<k;i++)
int main() {
int n;
cin >> n;
rep(i, 0, n) {
cin >> num[i];
hashtable[num[i]]++;
}
rep(i, 0, n)
if (hashtable[num[i]] == 1) {
cout << num[i];
return 0;
}
cout << "None";
}
doubt
I don't know why I'm wrong ╮(╯_╰)╭
using namespace std;
#include <unordered_map>
#define rep(i,j,k) for(int i=j;i<k;i++)
#include <iostream>
int main() {
unordered_map<int, int>bets;
int n, temp;
cin >> n;
rep(i, 0, n) {
cin >> temp;
bets[temp]++;
}
for (auto i : bets) {
//cout << i.second << endl;
if (i.second == 1) {
cout << i.first;
return 0;
}
}
cout << "None";
return 0;
}
边栏推荐
- Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
- Vulnhub target: hacknos_ PLAYER V1.1
- Minio文件下载问题——inputstream:closed
- Unity场景跳转及退出
- JS regular expression basic knowledge learning
- [leetcode15] sum of three numbers
- 关于Gateway中使用@Controller的问题
- dosbox第一次使用
- level16
- AMBA、AHB、APB、AXI的理解
猜你喜欢
Database course design: college educational administration management system (including code)
[Red Treasure Book Notes simplified version] Chapter 12 BOM
idea中好用的快捷键
基於Redis的分布式ID生成器
SVN更新后不出现红色感叹号
(五)R语言入门生物信息学——ORF和序列分析
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)
Arm pc=pc+8 is the most understandable explanation
ESP8266连接onenet(旧版MQTT方式)
随机推荐
数据库课程设计:高校教务管理系统(含代码)
MySQL replacement field part content
Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
Esp8266 connect onenet (old mqtt mode)
(3) Introduction to bioinformatics of R language - function, data Frame, simple DNA reading and analysis
By v$rman_ backup_ job_ Oracle "bug" caused by details
Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)
Expected value (EV)
Vulnhub target: hacknos_ PLAYER V1.1
Navigator object (determine browser type)
[leetcode19] delete the penultimate node in the linked list
[Offer18]删除链表的节点
Redis based distributed ID generator
Flink late data processing (3)
Minio file download problem - inputstream:closed
Whistle+switchyomega configure web proxy
[leetcode15] sum of three numbers
ES6语法总结--上篇(基础篇)
gcc 编译选项
ESP learning problem record