hulk_baba's blog

By hulk_baba, history, 8 years ago, In English

Please go through this problem 716B. My idea is : 1. if length of string in less than 26 , print "-1" and return ; 2. calculate frequency of first 26 characters and then see how many characters are left out and how many '?' are available . 3. If left out == cnt['?'] it is possible. 4. If not go for next 26. 4. I tried it but failed on 18th test case here? Could you help me with my implementation. Or if you have more elegant implementation please suggest me.

  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

In m u maintain amount of symbols on suffix, not on a substring. If i understood correctly

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

here u are ..
link for your accepted code
what you were doing wrong was mapping all the characters of the string in one go rather than dealing with substring of length 26.
just have a look to changes i made.
i cannot say whether mine is elegant or not.
but you can refer mine too link for my accepted code