Correct approach for Cryptos : Core farrago

Hey, I don’t understand what is wrong with this logic, It gives WA for almost everyone and I don’t see any problem with the logic.

  1. If Any char present in W is not present in S, then answer is 0.
  2. If Any char present in W and it is also present in S, BUT
    count(of that character in S) < count(of that character in W), then 0
  3. else count(of that character in S) >= count(of that character in W)
    Now, do int division = count(of that character in S) / count(of that character in W);
    if division < min, then
    set min = division;

@sarthakmanna, @p_unit, @sachin_1234569, @skalra4321, @bhagatdivesh21

My sol : CodeChef: Practical coding for everyone

damn! missed this case. Thanks @aryanc403

I think we can solve in this way .
we can find the longest length of prefix less than the size of the string which matches with the suffix of string
if string is aaaa then the length will be len=3

so we are given another string whose characters we can rearrange , so we only need the frequency of the characters .

so we will try to form the first string by rearranging the characters of second string , then we have to only add the remaining length (excluding the prefix of length len) . so we have the frequency so we can find the maximum number of times we can replicate the string

I have not submitted this solution in the contest , please correct me if i am wrong

1 Like