[ SIGSEGV] ERROR - How to Avoid?

I get this error every time i solve any Dynamic programming problem. can anyone please help me by pointing out my mistake in this code.

Thank You!

arr has dimensions of 1x100000 but you’re trying to access the 2nd index which doest exist

thanks bro.

Just a suggestion, you can simply declare array as arr[1e6 + 1] or arr[1000001]. The two dimensional declaration is pointless to declare a 1 dimensional array!