Showing:
Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Why is Melody so chocolaty?
Basic Accuracy: 0.0% Submissions: 3 Points: 1

Chunky gets happy by eating Melody.
Given an array of N elements, each element represents happiness chunky get by eating melody.
Chunky knows why melody is so chocolaty but will only tell you once you tell him the Max happiness he can get by eating two adjacent melodies.

Example 1:

â€‹Input : arr[ ] = {1, 2, 3, 4, 5}
Output : 9
Explanation:
At index 0, arr[0] + arr[1] = 3
At index 1, arr[1] + arr[2] = 5
At index 2, arr[2] + arr[3] = 7
...
In this way, 9 will be the answer.


â€‹Example 2:

Input : arr[ ] = {1, 2, 3, 4}
Output :  7

This is a function problem. The input is already taken care of by the driver code. You only need to complete the function max_adjacent_sum() that takes an array (arr), sizeOfArray (n), and return the maximum happiness. The driver code takes care of the printing.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

Constraints:
2 ≤ N ≤ 105
-107 ≤ A[i] ≤ 107