Lets test your Java problem solving skill today First try it in brute force & you can use Array Sort and any built in functions. Then, Solve by using two pointers, Keep it in 2O(n). Solve the same for different situations like three adjacent numbers are of same value multiply that and keep it at the last and make the first two as zero.