What is the different between those code?

https://www.codechef.com/viewsolution/33319301
https://www.codechef.com/viewsolution/33346448
problem link: https://www.codechef.com/problems/CHEFRECP/
first code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;cin>>t;
while(t–)
{
map<int,int>mp,p;
int n,k,a=0,f=1;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>k;
if(a!=k&&mp[k]){cout<<“NO”<<endl;f=0;break;}
mp[k]++;
a=k;
}
if(f!=0){
for(auto i:mp)
{
if(p[i.second]){cout<<“NO”<<endl;f=0;break;}
p[i.second]++;
}
}
if(f)cout<<“YES”<<endl;
mp.clear();p.clear();
}
}
second code:
#include<bits/stdc++.h>

using namespace std;
int main()
{
int t; cin >> t;
for(;t–:wink:
{
int n; cin >> n;
int x, a[n + 1];

	map<int,int> mp;
	for(int i = 1; i <= n; i++)
	{
		cin >> x;
		a[i] = x;
	}
	
	int ok  = 0;
	for(int i = 1; i <= n; i++)
	{
	    if(i != 1 && mp[a[i]] >= 1 && a[i] != a[i - 1])
	    {
	        ok = 1;
	        break;
	    }
	    
	    mp[a[i]]++;
	}
	
	map<int,int> fin;
	for(auto i : mp)
	{
		fin[i.second]++;
	}
	
	for(auto i : fin)
	{
		if(i.second > 1)
		{
			ok = 1;
			break;
		}
	}
	
	if(ok == 0) cout << "YES\n";
	else cout << "NO\n";
	
	/*
	int vis[n + 1] = {0};
	int kk = 0;

	vis[a[1]] = 1;
	for(int i = 2; i <= n; i++)
	{
		if(a[i] == a[i - 1])
			vis[a[i]]++;
		else
		{
			if(vis[a[i]] != 0)
			{
				kk = 1;
				break;
			}
			else
			{
				vis[a[i]]++;	
			}	
		}	
	}	
	//cout << ok << " " << kk << "\n";
	if(ok == 0 && kk == 0)
		cout << "YES\n";
	else
		cout << "NO\n";

*/
}
return 0;

}