Here's a code challenge I got. (I could not solve the challenge, I ran out of time. I rephrased the challenge language and I am trying the challenge again for personal growth & computer science knowledge)
Consider an array A of N integers. You can delete zero or more of its elements.
Then take the remaining elements and reduce to an integer S according to these rules:
- elements in even positions are added
- elements in odd positions are subtracted: e.g. S = A[0] − A[1] + A[2] − A[3] + ...