LOST CHILDREN

# PROBLEM LINK

https://www.codechef.com/SOUT2021/problems/LC001

*Author:* Aman Nadaf

*Tester:* Aman Nadaf

*Editorialist:* Aman Nadaf

# DIFFICULTY:

Cakewalk

# PREREQUISITES:

Linear Search

# PROBLEM:

During a Fair Parents lost their child in the Crowd you are appointed as a Security Guard with a duty to find the particular child. You gather a group of N lost children in a Queue and try to find the child with id K given by his/her Parents. If the child is Found Inform the Parents about the Position of the child in queue else Inform Not Found. Help T such Parents to find their children.

# EXPLANATION:

So we had to take an array of size N (given) and find the position of the id K (given) and check if it is there or not in the array u can take a loop from 0 to n-1 and check if k==array[i] if found then print the position if not then print “ not found”.

# SOLUTIONS:

## Setter's Solution

```
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define vll vector<long long int>
int main()
{
int t;
cin >> t;
while (t--)
{
ll n, k, pos = 0;
cin >> n >> k;
ll a[n];
for (ll i = 0; i < n; i++)
cin >> a[i];
for (ll i = 0; i < n; i++)
{
if (a[i] == k)
{
pos = i + 1;
break;
}
}
if (pos == 0)
cout << "not found" << endl;
else
cout << pos << endl;
}
}
```

Feel free to share your approach here. Suggestions are always welcomed.

.