11991

All about problems in Volume CXIX. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

11991

Postby atiburrahman09 » Fri Jun 29, 2012 1:58 am

I need some Help....
i am trying to solve this problem. but i cann't understand this line.

"For each query, print the 1-based location of the occurrence. If there is no such element, output 0 instead."

Any help will be great....
atiburrahman09
New poster
 
Posts: 6
Joined: Mon Mar 26, 2012 10:12 pm

Re: 11991

Postby brianfry713 » Sat Jun 30, 2012 12:26 am

Sample Input
Code: Select all
8 4
1 3 2 2 4 3 2 1
1 3
2 4
3 2
4 2
Sample Output
Code: Select all
2
0
7
0

The array has 8 elements, position 1 through 8. First you are looking for the first 3, that is at position 2 in the array. Next you want the second 4, but since there is only one 4 print 0 instead. Next the third 2, which is at position 7. Finally the fourth 2, but there are only three 2's, so print 0 instead.
brianfry713
Guru
 
Posts: 1755
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA


Return to Volume CXIX

Who is online

Users browsing this forum: No registered users and 1 guest