Getting run errors

I checked the code logic and it looks fine to me.

The possible run error may be due to input values. Whatever was given, I tried doing the same. Please check.

hi @PThak2018 this is the exact input that is given in this questio. You have to consider the brackets and commas as well.

[3,1,4,null,2]
1