Weighted uniform strings
Hi chandra
There were many compilation errors in your program like misspelt vector and push_back.
Logical errors were:
- you need declare size of vector v = size of string s
- include an else part in for loop for assigning values in v
for(int i=0;i<s.length();i++)
{
if(s[i-1]==s[i])
{
v[i]=v[i-1]+a[s[i]-‘a’+1];
}
else
v[i]=a[s[i]-‘a’+1];
}
Hope it helps
Mark resolved if satisfied
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.