当前位置:网站首页>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;
}
边栏推荐
- (一)R语言入门指南——数据分析的第一步
- MySQL時間、時區、自動填充0的問題
- (四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
- GCC compilation options
- 基于Redis的分布式锁 以及 超详细的改进思路
- 关于Gateway中使用@Controller的问题
- Rough analysis of map file
- Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
- Single chip Bluetooth wireless burning
- JS function promotion and declaration promotion of VaR variable
猜你喜欢
Easy to use shortcut keys in idea
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
MySQL占用内存过大解决方案
MySQL takes up too much memory solution
记一次云服务器被密码爆破的经历——关小黑屋、改密码、改端口
Expected value (EV)
Walk into WPF's drawing Bing Dwen Dwen
2021.11.10 compilation examination
数据库课程设计:高校教务管理系统(含代码)
JS变量类型以及常用类型转换
随机推荐
Esp8266 uses Arduino to connect Alibaba cloud Internet of things
[Clickhouse kernel principle graphic explanation] about the collaborative work of partitioning, indexing, marking and compressed data
Gateway fails to route according to the service name, and reports an error service unavailable, status=503
Knowledge summary of request
[Leetcode15]三数之和
单片机蓝牙无线烧录
Imgcat usage experience
Common properties of location
NRF24L01 troubleshooting
Types de variables JS et transformations de type communes
程序设计大作业:教务管理系统(C语言)
ES6语法总结--上篇(基础篇)
About using @controller in gateway
Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
Remember an experience of ECS being blown up by passwords - closing a small black house, changing passwords, and changing ports
dosbox第一次使用
CUDA C programming authoritative guide Grossman Chapter 4 global memory
How to add music playback function to Arduino project
ORA-02030: can only select from fixed tables/views