# Write a class ElementCheckInEveryPair with a public method checkElement that takes two parameters one is arr of type int[] and second one is arg of type int and returns true if every pair of arr contains at least one arg

Write a class ElementCheckInEveryPair with a public method checkElement that takes two parameters one is arr of type int[] and second one is arg of type int and returns true if every pair of arr contains at least one arg.

Assumptions:

1. arr is never null

These are examples for your understanding:

```Enter no of elements in the array:
6
Enter elements in the array seperated by space:
52 2 3 2 65 2
Enter the search element:
2
true
```
```Enter no of elements in the array:
6
Enter elements in the array seperated by space:
4 5 4 1 1 4
Enter the search element:
4
false```

### Solution:

``````package q11082

public class ElementCheckInEveryPair {
/** * Find every pair of array contains atleast one arg
*
*
*
*
*@return result */
public boolean checkElement(int[] arr, int arg) {
int size = arr.length;
boolean result = false;

for(int i = 0; i < size; i++){
if(arr[i]==arg || arr[i+1]==arg){
result=true;

} else if(arr[i]!=arg || arr[i+1]!=arg){
result=false;
break;
}
}
return result;
}
}``````