Workshop Seats
Practice this coding question on Coding Gurukul.
Problem statement
Coding Gurukul is organising a programming workshop. There are N seats arranged in a single row. Booking seat i costs A[i] rupees. Two friends want to attend the workshop and sit next to each other. They must book exactly two adjacent seats. Find the minimum total booking cost. The first and last seats are not adjacent.
Input format
The first line contains an integer T — the number of test cases. For each test case: The first line contains an integer N — the number of seats. The second line contains N space-separated integers A[1], A[2], ..., A[N] — the booking costs.
Output format
For each test case, print the minimum total cost of two adjacent seats on a separate line.
Constraints
1 <= T <= 100 2 <= N <= 1000 1 <= A[i] <= 1000000
Sample input
3 5 8 3 6 2 7 2 10 20 4 1 100 100 1
Sample output
8 30 101
Sign in to run or submit a solution in C++, Java or Python.