Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language Jojo is given N integers, sorted in non-descending order, A 1, A 2, ..., A n by his teacher. His teacher also give

C language

Jojo is given N integers, sorted in non-descending order, A 1, A 2, ..., A n by his teacher. His teacher also give him M numbers, Q 1, Q 2, ..., Q m. For every number Q i that his teacher gave him, at what position does number Q i located? If there are several answers, you should print the position with the smallest number and if there is no answer, you should print -1.

Format Input : There will be 3 lines. The first line consist of two integers N and M. The second line consist of N integers A 1, A 2, ..., A n. The third line consist of M integers Q 1, Q 2, ..., Q m.

Format Output : Output M lines, the answer to the problem.

Constraints : 1 N, M, A i , Q i 10^5

Sample Input 1 (standard input) : 3 2 1 2 3 1 2

Sample Output 1 (standard output) : 1 2

Sample Input 2 (standard input) : 4 2 1 3 5 5 100 5

Sample Output 2 (standard output) : -1 3

Don't copy from other person answer . Thanks !

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

6. Describe to a manager the different types of distance learning.

Answered: 1 week ago