|
|
back to boardCan somebody help me, please Posted by Abbos 31 Jul 2016 15:14 What's the meaning of the question ? I tried to get it but in vain, even the test unclear for me Re: Can somebody help me, please I'll explain the test. 6 2 5 3 4 1 9 The first one is chosen as current candidate, and has 2 disadvantages. Then, he is compared with 2nd pirate (5 disadvantages), 3rd (3), 4th (4), 5th (1). When comparing with 5th pirate, we see that he has less disadvantages (1) than current candidate (2). So he becomes the current candidate. And then we finally compare him with last pirate (9 disadvantages). In the end, 1st pirate with 2 disadvantages was compared to 2nd, 3rd, 4th, 5th — compared 4 times; 2nd pirate with 5 disadvantages was compared to 1st — compared 1 times; 3rd pirate with 3 disadvantages was compared to 1st — compared 1 times; 4th pirate with 4 disadvantages was compared to 1st — compared 1 times; 5th pirate with 1 disadvantages was compared to 1st, 6th — compared 2 times; 6th pirate with 9 disadvantages was compared to 5th — compared 1 times; Out of all the pirates, the 1st one has the most compare times — 4. Thus, we output 1 — the index of a pirate who was compared most times. But, if several pirates were compared the same amount of times — say, if 5th one was also compared 4 times (if there were 2 more pirates in input) — then both answers "1" or "4" would be correct in this case. Is this any clearer? Re: Can somebody help me, please |
|
|