diff --git a/easy/day_14/solution.cpp b/easy/day_14/solution.cpp index 8d3ad8d..ab1cab1 100644 --- a/easy/day_14/solution.cpp +++ b/easy/day_14/solution.cpp @@ -1 +1,51 @@ -//write your code here \ No newline at end of file +#include +using namespace std; +int main() +{ + int t; + cin >> t; + while (t--) + { + int n; + cin >> n; + int arr[n]; + int count = 0; + for (int i = 0 ; i < n; i++) + { + cin >> arr[i]; + if (arr[i] == 2) + { + count++; + } + } + if (n == 1) + { + cout << -1 << endl; + continue; + ; + } + if (count % 2 == 1) + { + cout << -1 << endl; + continue; + } + + else + { + int count2 = 0; + int i = 0; + while (count2 <(count / 2)) + { + if (arr[i] == 2) + { + count2++; + } + i++; + } + if (i == 0) + i++; + + cout << i << endl; + } + } +} \ No newline at end of file