Here is the link to my solution. Can Someone explain where did i get wrong.
CodeChef: Practical coding for everyone .
aaaaab fails in your code…palindrome substrings are aba aaa…think how can you add to your logic
Bro odd freq number can also be divided into even +odd freq sum and this even freq can be used to compensate the single freq.
Case 1: when freq[i] ==1
Case 2: when freq[i] %2 ==0
Case 3 when freq [i] is odd and is greater than 3 that means it can be divide into odd +even and when I say greater than 3 because if freq is 3 then 3 will be divided into 2+1 and 2 will be used to compensate single freq but you will be still generating another 1 so we use greater than 3; and subtracting 1 as we donot want extra odd. like for ex 7 → 2 2 2 1. so we use 2 ,2 and leave 3 .as 3 is odd .only even compensate. so 7/2 -1 only 2 twos will be used or(7-3)/2 both are same way of writing it.
add this in your code
else if(f[i]>3){
even+=((f[i]-3)/2);
}
here is a link to my submission CodeChef: Practical coding for everyone
This Question PALPALS was a bad problem as the problem statement was not clear and misunderstood by many.It should not be considered for rankings.
Thankyou for your response.