Problem of the day
Input: [1,2,3,1]
Output: 4
Mr. X. can rob the first house and the third house, total money = 1 + 3.
Hence, the total money robbed by Mr. X. is 4.
The first line will contain the integer 'T', denoting the number of test cases.
The first line of each test case contains one integer 'N' denoting the size of array 'A'.
The second line of each test case contains 'N' single space-separated integers, elements of the array 'A'.
For each test case, Return the maximum amount of money Mr. X can rob tonight without alerting the police.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 10^5
0 <= A[i] <= 10ٰ^9
Time Limit: 1 sec
2
4
4 1 6 10
5
2 5 8 9 1
14
14
For the first case:
Input: [4,1,6,10]
Output: 4
Mr. X. can rob the first house and the fourth house, total money = 4 + 10.
Hence, the total money robbed by Mr. X. is 14.
For the second case:
Input: [2,5,8,9,1]
Output: 14
Mr. X. can rob the second and fourth houses, total money = 5 + 9.
Hence, the total money robbed by Mr. X. is 14.
2
8
6 1 50 1 50 30 6 100
6
55 19 21 13 10 67
206
143