

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
$\color{#1fdb91}{\texttt{C}}\color{#0aaec9}{\texttt{+}}\color{#e9418e}{\texttt{+}}$
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll c['z' + 5];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ll n; cin >> n; cin.ignore();
string s; getline(cin, s);
ll res=0;
for (ll i=0; i<n; ++i) {
res += c[s[i]];
++ c[s[i]];
}
cout << res;
}
$\\$
\begin{array}{c|c|c}\color{#ffd710}{\texttt{\{}} \color{#8655d6}{\texttt{\{}}\ \ \color{#8cdcda}{\text{Daoanhviet96}}\ \ \color{#8655d6}{\texttt{\}}} \color{#ffd710}{\texttt{\}}}\end{array}
Hãy giúp mọi người biết câu trả lời này thế nào?
![]()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
string s;
ll n,kq=0;
cin>>n>>s;
ll dem[26]={0};
for(ll i=0; i<n;++i) {
kq+=dem[s[i]-'a'];
dem[s[i]-'a']++;
}
cout<<kq;
return 0;
}Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin