3 sum problem, cubic and quadratic solutions