

Suppose given ‘BILL_ARR’ array is { 5, 5, 5, 10, 20 } so we return ‘True’ for this test case as from first ‘3’ customers we take ‘5$’ from each customer then ‘4th’ customer give ‘10$’ we give him ‘5$’ back now we have ‘2’, ‘5$’ note and ‘1’, ‘10$’ note than ‘5th’ customer give ‘20$’ so we give him back one ‘10$’ and one ‘5$’ note.
The first line of input contains a ‘T’ number of test cases.
The first line of each test case contains an integer ‘N’ i.e size of the array ‘BILL_ARR’.
The second line of each test case contains an array ‘BILL_ARR’, where ‘BILL_ARR[i]’ denotes the money paid for ‘i-th’ shikanji.
For each test case, print ‘True’ if it is possible else print ‘False’.
1. You don’t have any changes at starting.
2. You are not required to print anything explicitly. It has already been taken care of. Just implement the function.
1 <= T <= 10^2
1 <= N <= 10^3
BILL_ARR[i] = [ ‘5’, ‘10’, ‘20’ ]
Where ‘T’ represents the number of test cases and ‘N’ represents the size of the array and ‘BILL_ARR[i]’ represents the elements of the array.
Time Limit: 1 sec
Approach: The idea here is to use a ‘2’ variables for count instead of a map and whenever we strike some note can check the count of variables to check whether we can able to give change or not.
The algorithm is as follows: