diff --git a/First and Last occurrence of X b/First and Last occurrence of X new file mode 100644 index 0000000..64727ae --- /dev/null +++ b/First and Last occurrence of X @@ -0,0 +1,31 @@ + vector find(int arr[], int n , int x ) +{ + // code here + vector ans; + + for(int i=0;i=0;i--) + { + if(arr[i]==x) + { + ans.push_back(i); + break; + } + } + if(ans.size()==0) + { + ans.push_back(-1); + ans.push_back(-1); + return ans; + } + else{ + return ans; + } +}