一、技术总结

  1. 这题在思考的时候遇见了,不知道怎么处理输入顺序问题,虽然有记录每个的次数,事后再反过来需要出现一次的且在第一次出现,

    这时我们其实可以使用另一个数组用来存储输入顺序的字符,然后再用另一个数组记录出现的次数,这样就可以解决这个问题了。
  2. 如果使用cin出现运行超时的情况可以改用scanf,但是这个我运行的时候没有出现超时。
  3. 我把下列代码
int number[N];
改成
int number[10010];

然后提交出现段错误。不知道什么原因。。。。。

二、参考代码:

#include<iostream>
using namespace std;
int hashTable[10010];
int main(){
int N;
cin >> N;
int number[N];
int index = -1;
for(int i = 0; i < N; i++){
cin >> number[i];
hashTable[number[i]]++;
}
for(int i = 0; i < N; i++){
if(hashTable[number[i]] == 1){
index = number[i];
break;
}
}
if(index == -1){
cout << "None";
}else{
cout << index;
}
return 0;
}

A1041 Be Unique (20 分)的更多相关文章

  1. PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)

    1041 Be Unique (20 分)   Being unique is so important to people on Mars that even their lottery is de ...

  2. PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...

  3. PAT Advanced 1041 Be Unique (20 分)

    Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...

  4. 1041 Be Unique (20分)(水)

    Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...

  5. PAT 1041 Be Unique (20分)利用数组找出只出现一次的数字

    题目 Being unique is so important to people on Mars that even their lottery is designed in a unique wa ...

  6. 【PAT甲级】1041 Be Unique (20 分)(多重集)

    题意: 输入一个正整数N(<=1e5),接下来输入N个正整数.输出第一个独特的数(N个数中没有第二个和他相等的),如果没有这样的数就输出"None". AAAAAccepte ...

  7. 1041 Be Unique (20 分)

    1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...

  8. PAT 甲级 1041 Be Unique (20 分)

    1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...

  9. pat 1041 Be Unique(20 分)

    1041 Be Unique(20 分) Being unique is so important to people on Mars that even their lottery is desig ...

随机推荐

  1. LeetCode 841:钥匙和房间 Keys and Rooms

    题目: ​ 有 N 个房间,开始时你位于 0 号房间.每个房间有不同的号码:0,1,2,...,N-1,并且房间里可能有一些钥匙能使你进入下一个房间. ​ 在形式上,对于每个房间 i 都有一个钥匙列表 ...

  2. LeetCode28——实现strStr()

    6月中下旬辞职在家,7 月份无聊的度过了一个月.8 月份开始和朋友两个人写项目,一个后台和一个 APP ,APP 需要对接蓝牙打印机.APP 和蓝牙打印机都没有搞过,开始打算使用 MUI 开发 APP ...

  3. vuex 源码分析(五) action 详解

    action类似于mutation,不同的是Action提交的是mutation,而不是直接变更状态,而且action里可以包含任意异步操作,每个mutation的参数1是一个对象,可以包含如下六个属 ...

  4. linux (centos)增删改查用户命令

    1,查看用户 cat /etc/passwd 2,删除用户 userdel 用户名 3,查看组 cat /etc/group 4,删除组 groupdel 组名 5.查看系统中有哪些用户: cut - ...

  5. RocketMQ多master多salve集群搭建

    一.RocketMQ集群模式简介 单Master方式 风险比较大, 一旦Broker重启或者宕机, 将导致整个环境不可用, 不建议线上使用. 多Master模式 一个集群中没有slave, 全是mas ...

  6. jetty9部署

    https://blog.51cto.com/5404542/1751702     Jetty 9部署web应用 Jetty相关的文章比较少,不过官方文档挺齐全的.做下记录也是好事. jetty9跟 ...

  7. Java学习——网络编程

    Java学习——网络编程 摘要:本文主要介绍了什么是网络编程,以及如何使用Java语言进行网络编程. 部分内容来自以下博客: https://www.cnblogs.com/renyuan/p/269 ...

  8. Java网络编程 -- AIO异步网络编程

    AIO中的A即Asynchronous,AIO即异步IO.它是异步非阻塞的,客户端的I/O请求都是由OS先完成了再通知服务器应用去启动线程进行处理,一般我们的业务处理逻辑会变成一个回调函数,等待IO操 ...

  9. 关于javascript,多种函数封装!!

    1.获取最终的属性 function getStyleAttr(obj, attr){ if(window.getComputedStyle){ return window.getComputedSt ...

  10. Redis入门学习(二):下载安装

    Linux操作系统 Download, extract and compile Redis with: $ wget http://download.redis.io/releases/redis-4 ...