What is wrong with my solution of BUY1GET1

The problem : BUY1GET1 Problem - CodeChef
The (wrong) solution: CodeChef: Practical coding for everyone

I am simply counting the occurence of each alphabet in the given string and then calculating the price having accounted for duplicates.
It is able to give the correct output for the 1 sample input and when I try changing values it seem to give the correct output as well so I’m not sure what the problem is. I don’t seem to be formatting the ouptut incorrectly either.

Hi @shramanjain1, as given in the question, Input is case sensitive that is A and a are considered different here. So

1
Aa

Output: 2

Your Output: 1

1 Like

Your Code is Not Got AC Due to input constraints. input can be either capital case or small case but you are storing occurences for small case and capital case on same indices of array n.

1 Like