this is the question of last third question LSU LSU
i don’t know why my code getting ac my core logic is just see which one to take for minimum
void coderaryan()
{
// executing code from here
int t;
cin >> t;
while (t--)
{
int n, v;
cin >> n >> v;
string s;
cin >> s;
set<char> st;
set<char> sat;
for (auto i : s)
{
sat.insert(i);
}
int ans = 0;
for (int i = 0; i < n; i++)
{
if (i + 1 < v)
{
ans += min(i + 1, v);
}
else
{
if (st.find(s[i]) != st.end())
{
ans += 0;
}
else
{
st.insert(s[i]);
ans += v;
}
}
}
cout << min(ans,sat.size()*v) << endl;
}
}