From 28a2876865479781c8ef3a7d55576a7dd4c7510d Mon Sep 17 00:00:00 2001 From: Pragya Sharma <147252670+pragya79@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:02:45 +0530 Subject: [PATCH] Create first_repeating_element.cpp --- 09. Hashing/first_repeating_element.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 09. Hashing/first_repeating_element.cpp diff --git a/09. Hashing/first_repeating_element.cpp b/09. Hashing/first_repeating_element.cpp new file mode 100644 index 00000000..1e69d1f0 --- /dev/null +++ b/09. Hashing/first_repeating_element.cpp @@ -0,0 +1,18 @@ + +class Solution { + public: + // Function to return the position of the first repeating element. + int firstRepeated(int arr[], int n) { + // code here + unordered_map m; + for(int i=-1;i1){ + return arr[i]; + } + } + return -1; + } +};