Please review my code

i have implemented the logic explained but not getting the required output
please find my error

@rsumitaj there is typing error at line 12 in for-loop of bj.

Also please mark this doubt as resolved if you are able to solve it now.