N26 Interview Question

Medium level DP problem - hills and valleys