Array Counters

Back to General discussions forum

Maxim_Agaltsov     2018-01-16 21:13:19

task #21

Your input data:

261 10

7 3 2 9 3 1 2 2 4 9 4 10 2 7 5 4 9 1 9 1 1 2 5 4 2 9 1 6 1 2 10 8 4 1 6 7 2 8 8 6 7 2 5 8 8 10 2 6 10 1 7 1 2 1 4 3 10 4 9 10 6 8 8 10 9 4 6 1 1 4 6 8 5 1 5 2 10 7 8 9 7 4 9 8 5 2 1 4 6 9 4 1 7 1 1 6 4 6 6 5 10 2 2 5 2 7 7 1 3 4 10 9 8 8 7 2 10 7 5 6 5 9 7 2 9 7 7 3 3 3 7 2 5 9 6 6 5 2 7 8 6 6 7 3 4 3 5 3 9 10 9 4 8 5 6 7 1 3 9 3 5 6 5 9 4 1 5 9 2 2 6 8 7 3 1 10 5 5 3 4 5 2 7 2 6 2 8 7 5 6 10 9 2 4 8 5 4 3 3 6 4 9 4 1 1 4 10 6 8 3 9 2 4 6 4 10 7 2 6 1 8 6 10 9 9 8 3 3 1 6 9 4 5 2 4 5 5 4 1 3 7 9 5 1 4 8 10 1 9 6 2 6 1 2 4 10 9 7 2 9 2

Your answer was: 25 20 33 29 20 29 33 33 30 29

Expected answer was: 29 33 20 30 26 29 25 21 29 19

My answer is not Wrong!

WakeMeAtThree     2018-01-17 04:08:14
User avatar

Expected answer...

29 33 20 30 26 29 25 21 29 19

is correct. Try a shorter input that you can verify easily to test your code, like

20 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10

which should return array counter as:

[2 2 2 2 2 2 2 2 2 2]

Or maybe try a slightly different input.

55 10
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10

which should return array counter as:

[1 2 3 4 5 6 7 8 9 10]

See if you can use these inputs to debug your code. Not sure how you implemented it but here's a small hint. You can think of the array counter as always starting with:

[0 0 0 0 0 0 0 0 0 0]
There are 10 indices here.

Good luck.

Please login and solve 5 problems to be able to post at forum