Exist OR Not Problem

https://ide.geeksforgeeks.org/3N3KAXC62X-----this code is giving no such element exception at line 18 and also showing the wrong output please make correction in the code and point them out.

Hey @AbhishekAhlawat1102
Code is fine just a changes
int arr[] = new int[l]; instead of int arr[] = new int[l+1];
correct code :