Weighted uniform strings

https://hackerrank-challenge-pdfs.s3.amazonaws.com/32212-weighted-uniform-string-English?AWSAccessKeyId=AKIAJ4WZFDFQTZRGO3QA&Expires=1574406580&Signature=kDzt%2Fc3FphPIGTkYW%2FWzDNEpJq0%3D&response-content-disposition=inline%3B%20filename%3Dweighted-uniform-string-English.pdf&response-content-type=application%2Fpdf-question


.it was getting wrong

Hi chandra
There were many compilation errors in your program like misspelt vector and push_back.
Logical errors were:

  1. you need declare size of vector v = size of string s
  2. 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 :slight_smile:

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.