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).
Memorise Me!——用数值做地址,实现快速查找的更多相关文章
- Java String Integer转换 练习:编程求字符串“100”和“150”按十进制数值做差后的结果以字符串形式输出。
package com.swift; public class String_To_Integer_Test { public static void main(String[] args) { /* ...
- PHP实现文本快速查找 - 二分查找
PHP实现文本快速查找 - 二分查找法 起因 先说说事情的起因,最近在分析数据时经常遇到一种场景,代码需要频繁的读某一张数据库的表,比如根据地区ID获取地区名称.根据网站分类ID获取分类名称.根据关键 ...
- Eclipse添加快速查找Dao中方法所对应的Mybatis XML映射SQL的插件
Dao关联Mybatis快速查找的插件安装地址:http://dl.bintray.com/harawata/eclipse 安装步骤: ①Eclipse ==> Help ==> Ins ...
- jQuery实现的快速查找
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- vim之快速查找功能
vim有强大的字符串查找功能. 我们通常在vim下要查找字符串的时候, 都是输入 / 或者 ? 加 需要查找的字符串来进行搜索,比如想搜索 super 这个单词, 可以输入 /super 或者 ...
- 如何快速查找到多个字典中的公共键(Key)---Python数据结构与算法相关问题与解决技巧
如何快速查找到多个字典中的公共键(Key)-? 实际案例: 西班牙足球甲级联赛,每轮球员进球统计: 第1轮: { '苏亚雷斯':1,'梅西':2,'本泽马':1,...} 第2轮: { '苏亚雷斯 ...
- (私人收藏)[开发必备]HTML5最全快速查找离线手册(可查询可学习,带实例)
[开发必备]HTML5最全快速查找离线手册(可查询可学习,带实例) HTML5最全快速查找离线手册:https://pan.baidu.com/s/19seE8TJQSx4IsWgXtKQS0Aj9y ...
- (私人收藏)[开发必备]最全Java离线快速查找手册(可查询可学习,带实例)
(私人收藏)[开发必备]最全Java离线快速查找手册(可查询可学习,带实例) https://pan.baidu.com/s/1L54VuFwCdKVnQGVc8vD1TQnwmj java手册 Ja ...
- [SQL Server]如何快速查找使用了某个字段的所有存储过程
[SQL Server]如何快速查找使用了某个字段的所有存储过程 当一个系统中使用了很多的表,并且存在大量的存储过程,当数据库中的某个表删除了某个字段,那么相应的存储过程也需要改动,但是我 ...
随机推荐
- LinuxCPU性能监控工具---mpstat
mpstat是 Multiprocessor Statistics的缩写,是实时系统监控工具.其报告与CPU的一些统计信息,这些信息存放在/proc/stat文件中.在多CPU系统里,其不但能查看所有 ...
- 《精通Spring+4.x++企业应用开发实战》读后感
引言 还记得大三时上培训班的是时候,当时的培训老师说自己是本地讲解spring最好的讲师,但是后来等我实习了看了<Spring 3.x 企业应用开发实战>以及后续版本<精通Sprin ...
- hadoop dfs.datanode.du.reserved 预留空间配置方法
对于datanode配置预留空间的方法 为:在hdfs-site.xml添加如下配置 <property> <name>dfs.datanode.du.reserved< ...
- EL概述和EL11个隐含对象
jsp有内置对象,当然EL也有隐含对象,EL的隐含对象类似于JSP内置对象.隐含对象分为三类,下面对11个隐含对象进行概述: 1.页面上下文对象(pageContext)1个 pageContext对 ...
- SQL ROUND() 函数
ROUND() 函数 ROUND 函数用于把数值字段舍入为指定的小数位数. SQL ROUND() 语法 SELECT ROUND(column_name,decimals) FROM table_n ...
- React 特性剪辑(版本 16.0 ~ 16.9)
Before you're going to hate it, then you're going to love it. Concurrent Render(贯穿 16) 在 18年的 JSConf ...
- easyui-tab标签
一. 加载方式 //class 加载方式<div id="box" class="easyui-tabs" style="width:500px ...
- photoshop快速把新照片制作成老照片教学
原图 步骤1 在photoshop中找开需要处理的图片,Ctrl+J复制图片,得到图片1. 步骤2 单击图层面板底部的创建新的填充或调整图层图标,添加色调/饱和度调整图层.调整它的饱合度和明度. 步骤 ...
- 阿里云 轻量应用服务器(LAMP) 使用日志记录
phpStudy(PHP运行环境一键安装包) https://www.jb51.net/softs/182860.html 0:PHP开发工具 https://netbeans.org/downloa ...
- Apache Tomcat 7 Configuration BIO NIO AIO APR ThreadPool
Apache Tomcat 7 Configuration Reference (7.0.93) - The Executor (thread pool)https://tomcat.apache.o ...