Help me with problem Buy1-Get1

Problem Link:- https://www.codechef.com/problems/BUY1GET1
Solution link :- https://ideone.com/jW3pPU
Please guide me if my logic is correct as i am getting runtime error(SIGABRT) even if it is running well. Was my logic correct i.e, compromising time and space complexity would the program run on this logic?

Your logic is correct.
However you did not read the statement correctly.
The input string can contain a-z and A-Z.
Your code tries to access invalid array location (-ve) for A-Z hence it gives SIGABRT.

Fix this and it should work.

Thanks for your help