This isn't a HackerRank challenge - just something I wanted to try.
Find the sum of the top K non-adjacent integers in a list.
The first line contains a single integer T, the number of test cases. For every test case, the first line contains a single integer N, where N is the size of the list. The next line contains a single integer K. The following line contains N integers {a1, a2 ... aN}.
You can execute python3 generator.py
to create some random input data.
0 <= T <= 232 - 1
0 <= N <= 232 - 1
0 < K <= N
0 <= ai <= 232 - 1
For each test case, print the sum of the top K non-adjacent integers of the list or -1 if it is not possible to pick K non-adjacent integers.
1
5
3
1 2 3 4 5
9
5 + 3 + 1 = 9