Marks :10
: 2 | : 0
Given N boxes containing a different number of books in each box (numBook[i]), take a minimum number of books from the boxes conditions are such that:
You must take either all or none books inside a given box
Firstly, you cannot skip taking books from boxes adjacent to each other. Box 1 and 2 can not be skipped but you can skip boxes 1 and 3.
Secondly, you cannot take books from boxes adjacent to each other. Box 1 and 2 can not be taken but you can take boxes 1 and 3.
You must have a minimum number of books in your hand.
The first line of each test case contains a single integer N ($$$ 1 \le N \le 100$$$)
The next line contains an array of size N.
For each test case print the minimum number of books
5 1 3 4 2 3
5
For example :
If there are 6 boxes and the number of books in the box are {7,2,13,12,9,1} then the minimum number of books u can take is 15(By skipping box 1,3,5)
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.