HackerEarth Even Length Palindromic Number problem solution YASH PAL, 31 July 2024 In this HackerEarth Even Length Palindromic Number problem solution You have to design a new model which maps an even length palindromic number to some digit between 0 to 9. The number is mapped to a digit on the basis of the following criteria: x should appear a maximum number of times in the palindromic number, that is, among all digits in the number, x should appear a maximum number of times. If more than one digit appears a maximum number of times, should be the smallest digit among them. Given an integer N, you have to find the digit x for the Nth even length palindromic number. HackerEarth Even Length Palindromic Number problem solution. #include<bits/stdc++.h>#define ll unsigned long long#define ld long double#define mp make_pair#define pb push_back#define si(x) scanf("%d",&x)#define pi(x) printf("%dn",x)#define s(x) scanf("%lld",&x)#define p(x) printf("%lldn",x)#define sc(x) scanf("%s",x)#define pc(x) printf("%s",x)#define pii pair<int,int>#define pll pair<ll,ll>#define F first#define S second#define inf 4e18#define prec(x) fixed<<setprecision(15)<<x#define all(x) x.begin(),x.end()#define rall(x) x.rbegin(),x.rend()#define mem(x,y) memset(x,y,sizeof(x))#define PQG priority_queue< int,std::vector<int>,std::greater<int> >#define PQL priority_queue< int,std::vector<int>,std::less<int> >#define PQPL priority_queue<pii ,vectosr< pii >, less< pii > >#define PQPG priority_queue<pii ,vector< pii >, greater< pii > >#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)using namespace std;int main() { #ifndef ONLINE_JUDGE freopen("in09.txt","r",stdin); freopen("out09.txt","w",stdout); #endif int q; cin>>q; while(q--) { string s; cin>>s; int cnt[10]; mem(cnt,0); for(char c:s) { cnt[c-'0']++; } int mx=-1,dig; for(int i=0;i<10;i++) { if(cnt[i]>mx) { mx=cnt[i]; dig=i; } } cout<<dig<<endl; } return 0; } Second solution #include<bits/stdc++.h>#define ll long longusing namespace std;int main(){ int t; cin>>t; while(t--) { ll n; cin>>n; int f[10]={0}; while(n) { f[n%10]++; n/=10; } int index,ans=0; for(int i=0;i<=9;i++) { if(ans<f[i]) { ans=f[i]; index=i; } } cout<<index<<"n"; } return 0;} coding problems