Ways to Reach After K Steps

On an infinite number line, count distinct sequences of ±1 moves that reach a target position in exactly k steps. The answer is C(k, (k + d)/2) where d is the distance, if (k-d) is non-negative and even.

Examples
Input: [1,2,3]
Output: 3
Hints

Ways to Reach After K Steps

On an infinite number line, count distinct sequences of ±1 moves that reach a target position in exactly k steps. The answer is C(k, (k + d)/2) where d is the distance, if (k-d) is non-negative and even.