I don't understand the explanation. Could you give a few more examples showing where the result numbers come from? At least could you explain where 2 and 1 come from in the first example? And 3,2 in the second?

If you need to count the number of times k appears next to a number less than itself, and the number of times it appears next to a number greater than itself, then given the 10 integers 9, -7, 23, 8, 9, 9, 13, 9, -11, 5 surely the output must be 2 (because the 3rd and 4th 9s are less than 13) and 3 (because 9 is greater than -7,8 and -11), not 2 and 1.

Also example 2 doesn't add up (-5, 0, 3, 17, -998, 0, -12, 0, 0, 0). 0 appears next to -5,-998 and -12 twice, so "less than" is 4 (or 3 if we're only counting the second 0 once; I'm counting it twice because the second 0 is greater than both -998 and -12)), and it appears next to 3, so "greater than" is only 1. So again I don't see where the prescribed output 3,2 comes from.

Your friend's example is not right, by the way. In the j loop, on the first iteration when j==0, it refers to Vector[j-1] which is Vector[-1]. While this will compile and run [because arr[n] is just shorthand for *(arr+n) ], since Vector is not a pointer into the middle of an array but the start of an array, this means the program exhibits undefined behaviour.

If you had something like int n[20]; int *Vector=&n[10]; then all negative indices of Vector from -1 to -10 would be fine.