better solution for max product array