## Array practice 1

Points: 1
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Python3

This practice problem will require you to programme basic array operations.

You are hired to offer phone number look up service for a company's internal network. The company has $$N$$ employees with employee ID $$0$$ to $$N-1$$. Your job is to when asked for the phone number for employee $$i$$, output that person's number on screen.

#### Input Specification

The first line will contain two integers $$N$$ and $$M$$ ($$1 < N,M < 10000$$), indicating the number of employees in your directory, and the number of queries.

The following $$N$$ lines will each contain a single integer $$P$$ ($$1 < P < 1000000$$), indicating the an employee's phone number.

Then, the next $$M$$ lines will each contain a query for phone number by a single integer, which is the employee's ID.

#### Output Specification

There should be $$M$$ lines in your output, each an integer for the phone number that is asked.

Should the query ask for an employee not on the directory ($$P > N-1$$), output No entry.

#### Sample Input

5 3
1024
2048
7789
4321
42
2
7
3

#### Sample Output

7789
No entry
4321

## Comments

• Mais  commented on March 23, 2021, 8:14 a.m.

### Take number of employees and number of queries as input

N, M = input().split()

N = int(N)

M = int(M)

### Take employee's phone numbers as input into an array(list)

Phone = []

for i in range(N):

P = int(input())

Phone.append(P)

### Take queries as input into an array(list)

Query = []

for i in range(M):

Q = int(input())

Query.append(Q)

### Iterate through the queries

for Q in Query:

# Display "No entry" if an employee is not on the directory

if Q>N-1:

print("No entry")

# Otherwise display the phone number of the employee stored in the array Phone

else:

print(Phone[Q])