File tree 1 file changed +78
-0
lines changed
1 file changed +78
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+ struct Array {
4
+ int * A;
5
+ int size;
6
+ int length;
7
+ };
8
+
9
+ int Min (struct Array * arr) {
10
+ int min = INT_MAX;
11
+ for (int i = 0 ; i < arr->length ; i++) {
12
+ if (arr->A [i] < min)
13
+ min = arr->A [i];
14
+ }
15
+ return min;
16
+ }
17
+
18
+ int Max (struct Array * arr) {
19
+ int max = INT_MIN;
20
+ for (int i = 0 ; i < arr->length ; i++)
21
+ if (arr->A [i] > max)
22
+ max = arr->A [i];
23
+ return max;
24
+ }
25
+
26
+ void Count_Find_duplicate_hash (struct Array * arr) {
27
+ int * H;
28
+ H = new int [Max (arr)]{ 0 };
29
+ for (int i = 0 ; i < Max (arr); i++)
30
+ H[i] = { 0 };
31
+ for (int i = 0 ; i < arr->length ; i++)
32
+ H[arr->A [i]]++;
33
+ for (int i = Min (arr); i <= Max (arr); i++) {
34
+ if (H[i] > 1 )
35
+ cout << i << " is duplicate element and appering for " << H[i] << " Times" <<endl;
36
+ }
37
+ }
38
+ int main () {
39
+ struct Array arr;
40
+ int no;
41
+ cout << " Enter the size of the array " << endl;
42
+ cin >> arr.size ;
43
+ arr.A = new int [arr.size ];
44
+ arr.length = 0 ;
45
+ cout << " Enter the size of the array" << endl;
46
+ cin >> no;
47
+ cout << " Enter the elements of the array " << endl;
48
+ for (int i = 0 ; i < no; i++)
49
+ cin >> arr.A [i];
50
+ arr.length = no;
51
+
52
+ Count_Find_duplicate_hash (&arr);
53
+
54
+
55
+ // Display(arr);
56
+ return 0 ;
57
+
58
+ }
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ // ---------------------------------------------------------------------------------------------------------------------------------------------
78
+
1
79
#include < iostream>
2
80
using namespace std ;
3
81
int main ()
You can’t perform that action at this time.
0 commit comments