largest sum of non-adjacent numbers.

This Question Was Asked By Airbnb

There is an array of integers given. You have to return the largest sum of non-adjacent numbers.

Write a function solve that have the following parameter(s):
1.) arr = an array of integer

Example
Input:
[2, 4, 6, 8]
Output:
The function will return,
12

Explanation
The sum of two non-adjacent numbers 4 and 8 from an array [2, 4, 6, 8] will be 12.

Constraints
• Number of the elements in the array will be greater than or equal to 1 and less than or equal to 800.
• Each element in an array will be 0 or negative or less than 1000.