-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path122191442.cpp
More file actions
69 lines (67 loc) · 1.51 KB
/
122191442.cpp
File metadata and controls
69 lines (67 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
using namespace std;
class Node {
public:
long long int data;
Node *next;
};
Node *start = NULL;
int main()
{
unsigned long int arr[4] = {0};
for(int i=0; i<4; i++){
cin>>arr[i];
}
for(int i=0; i<4; i++){
int temp = arr[i];
int count = 0;
int found = 1;
if(start==NULL){
Node *ptr = new Node();
ptr->data=temp;
ptr->next=NULL;
start=ptr;
}else{
Node *ptr = start;
while(ptr->next!=NULL){
if(ptr->data == temp){
found = 2; //2 means success, means found
}
ptr=ptr->next;
}
if(ptr->data == temp){
found = 2; //2 means success, means found
}
if(found!=2){
Node *ptr2 = new Node();
ptr2->data = temp;
ptr2->next = NULL;
ptr->next = ptr2;
}
}
}
int total_shoes=0;
Node *ptr = start;
while(ptr!=NULL){
int count=0;
int temp = ptr->data;
for(int j=0; j<4; j++){
if(arr[j]==temp){
count++;
}
}
if(count>1){
total_shoes = total_shoes + (count-1);
}
ptr=ptr->next;
}
/*
Node *ptr = start;
while(ptr!=NULL){
cout<<ptr->data <<" ";
ptr=ptr->next;
}
*/
cout<<total_shoes;
return 0;
}