I wrote a solution but was advised against posting complete solutions, as it tends to attract those who want only to pass a test without exercising skill. There's some loss of learning by example, but it also reduces placing the incompetent in jobs where those skills are required, so it's a chosen policy I shall abide.
The requirement is to produce an output something like:
Originally Posted by
output
3 occurrences of the value 10 in the index range (1 ... 7), at indexes [1, 2, 7]
To get maximum (and minimum) indexes, we can first set a variable maxIndex to it's smallest value. Then while looping through each test case, compare a found index against maxIndex to update it.
To get the list of indexes, add each found index to a list of foundIndexes
Yes I know it's indices, but that's just so odd XD