# HackerEarth Illegible String problem solution

In this HackerEarth Illegible String problem solution, Your friend Max has written a string S in your textbook. The string consists of lowercase Latin letters. The problem is that Max is not good at writing at all! Especially, you never know if he wanted to write "w" or two consecutive "v". Given the string S, return the minimum and maximum length of a word which can be represented by it. The input string represents what you initially think the word is.

## HackerEarth Illegible String problem solution.

`#include <iostream>#include <cstdio>#include <string>#include <sstream> #include <vector>#include <set>#include <map>#include <queue>#include <stack>#include <cmath>#include <algorithm>#include <cstring>#include <ctime>#include <cassert>using namespace std;#define pb push_back#define mp make_pair#define pii pair<int,int>#define vi vector<int>#define SZ(x) ((int)(x.size()))#define fi first#define se second#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))#define IN(x,y) ((y).find((x))!=(y).end())#define ALL(t) t.begin(),t.end()#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)#define REMAX(a,b) (a)=max((a),(b));#define REMIN(a,b) (a)=min((a),(b));#define DBG cerr << "debug here" << endl;#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;typedef long long ll;int main()    {    ios_base::sync_with_stdio(0);    string s;    int n;    cin >> n;    cin >> s;    int m = 0, M = 0;    int run_w = 0, run_v = 0;    FOR(i, n)    {        if(s[i] == 'v') run_v++;        else if(s[i] == 'w') run_w++;        else        {            ++m;            ++M;            int vs = 2 * run_w + run_v;            M += vs;            m += ceil(vs / 2.0);            run_v = 0;            run_w = 0;        }    }    int vs = 2 * run_w + run_v;    M += vs;    m += ceil(vs / 2.0);    cout << m << " " << M << endl;    return 0;}`

### Second solution

`#include <bits/stdc++.h>using namespace std; string st;int n;int cnt,ans1,ans2; int main(){ cin>>n;cin>>st;for (int i=0;i<st.size();i++){   if (st[i]=='v')  {    cnt++;    continue;  }  if (st[i]=='w')  {    cnt+=2;    continue;  }  ans1+=cnt;  ans2+=cnt/2+cnt%2;  cnt=0;  ++ans1;  ++ans2;} ans1+=cnt;ans2+=cnt/2+cnt%2; cout<<ans2<<" "<<ans1<<endl; //cin.get();cin.get();return 0;}`