Memorise Me!——用数值做地址,实现快速查找
题目如下:
Arijit is a brilliant boy. He likes memory games. He likes to participate alone but this time he has to have a partner. So he chooses you.
In this Game , your team will be shown N numbers for few minutes . You will have to memorize these numbers.
Now, the questioner will ask you Q queries, in each query He will give you a number , and you have to tell him the total number of occurrences of that number in the array of numbers shown to your team . If the number is not present , then you will have to say “NOT PRESENT” (without quotes).
INPUT And OUTPUT
The first line of input will contain N, an integer, which is the total number of numbers shown to your team.
The second line of input contains N space separated integers .
The third line of input contains an integer Q , denoting the total number of integers.
The Next Q lines will contain an integer denoting an integer, Bi , for which you have to print the number of occurrences of that number (Bi) in those N numbers on a new line.
If the number Bi isn’t present then Print “NOT PRESENT” (without quotes) on a new line.
CONSTRAINTS
1≤N≤105
0≤Bi≤1000
1≤Q≤105
6 1 1 1 2 2 0 6 1 2 1 0 3 4
3 2 3 1 NOT PRESENT NOT PRESENT
The given array is (1,1,1,2,2,0) of size 6.
Total number of queries is 6 also.
For the first query i.e for 1 , the total of number of occurrences of 1 in the given array is 3 . Hence the corresponding output is 3.
For the second query i.e. for 2, the total of number of occurrences of 2 in the given array is 2 . Hence the corresponding output is 2.
For the fifth query i.e. for 3. 3 is not present in the array . So the corresponding output is "NOT PRESENT" (without quotes).
相关文章
- 基于编辑距离纯逻辑实现相似地址聚类
- 各个开源框架下载地址
- 共享OrCAD9.2pSpice9.2+multisim下载地址
- 小程序的下载地址!
- Linux 上的 MAC 地址欺骗
- web服务器获取请求客户端真实地址的方法
- JQuery实现 获取登录地址的IP和城市编码
- CentOS7 增加回环地址
- 高德地图实现地址检索获取结果列表和坐标
- img的src不连接本地地址实现输出一个图片(使用base64)
- Chrome插件下载地址
- MAC地址的介绍(单播、广播、组播、数据收发)
- SpringSecurity常见问题解决:设置忽略地址不生效的问题
- 【HMS Core】华为地图怎么通过详细地址返回经纬度
- TCP/IP具体解释学习笔记——地址解析协议ARP
- 实现财务自由 之 A 股上市公司的年报(年度财报)查阅查看、下载地址、以及下载的方法
- python解析URL中含有特殊符号的地址
- asp.net web项目 绑定ip地址运行方式
- URLRewrite地址重定向的实现
- php url链接地址传数组方法 json_decode解析数组失败 经过url链接的json数组解析出错的解决方法 (原)