Optimal stratagy 2 all last 3 testcases not working

@souravkhanna227 update the array size of dp as N<=10000,
also make it global if getting runtime error.