The fastest solution is given as

int Solution::solve(int A, int B, int C, int D) {

map<int,int> m;

m[A]++;

m[B]++;

m[C]++;

m[D]++;

```
if(m.size()==2)
{
for(auto it: m)
{
if(it.second!=2){return 0;}
}
return 1;
}
else
{
return 0;
}
```

}

Which return “0” on sqaure input like for example “4 4 4 4” which must return “1”.

This is because problem solver is only checking if map siize is 2 while in case of sqaure i can be also 1.

My approach to solve this problem was to neglect the wrong outcomes, which shrinnks the problem, checkout:-

int Solution::solve(int A, int B, int C, int D) {

map<int,int> m;

m[A]++;

m[B]++;

m[C]++;

m[D]++;

```
if(m.size()==2)
{
for(auto it: m)
{
if(it.second!=2){return 0;}
}
return 1;
}
else
{
return 0;
}
```

}