Can anyone please help me explain the solution? https://codeforces.net/problemset/problem/1307/C
ll dp[27][27] = {0}, cnt[27] ={0}; ll ans = 0; for (ll i = 0; i < str.length(); ++i) { for (ll j = 0; j < 26; ++j) dp[str[i] - 'a'][j] += cnt[j]; //what are we calculating using this dp and how cnt[str[i] - 'a']++; } for (ll i = 0; i < 26; ++i) { ans = max(ans, cnt[i]); for (ll j = 0; j < 26; ++j) ans = max(ans, dp[i][j]); } pf1(ans);