diff --git a/Find_First_and_Last_Position_of_an_Element_in_a_Sorted_Array.cpp b/Find_First_and_Last_Position_of_an_Element_in_a_Sorted_Array.cpp deleted file mode 100644 index f7865e0..0000000 --- a/Find_First_and_Last_Position_of_an_Element_in_a_Sorted_Array.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// C++ program to find first and last occurrence of -// an elements in given sorted array -#include -using namespace std; - -// Function for finding first and last occurrence -// of an elements -void findFirstAndLast(int arr[], int n, int x) -{ - int first = -1, last = -1; - for (int i = 0; i < n; i++) { - if (x != arr[i]) - continue; - if (first == -1) - first = i; - last = i; - } - if (first != -1) - cout << "First Occurrence = " << first - << "\nLast Occurrence = " << last; - else - cout << "Not Found"; -} - -// Driver code -int main() -{ - int arr[] = { 1, 2, 2, 2, 2, 3, 4, 7, 8, 8 }; - int n = sizeof(arr) / sizeof(int); - int x = 8; - findFirstAndLast(arr, n, x); - return 0; -} - -// This code is contributed by Aditya Kumar (adityakumar129)