Skip to content

Commit

Permalink
Merge pull request #147 from Kaizo8/shreshth
Browse files Browse the repository at this point in the history
feat: day 14 easy solution updated
  • Loading branch information
sanghaibiraj authored Apr 10, 2024
2 parents 1ca0ac9 + 6611705 commit f00ccd9
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion easy/day_14/solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
//write your code here
#include <bits/stdc++.h>
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;
}
}
}

0 comments on commit f00ccd9

Please sign in to comment.