Can you please tell where i am going wrong

your output array creating got too clumsy which was creating problem for the larger test cases
use this simplifed way. added comments for easier understanding


Hope this helps :slight_smile: