so check the picture below
notice, since you're cutting out a square, the sides must all be equal, thus the largest "x" can't be 2, half of 4, it has to be just less than 2 or it has no volume, so x<2, and can't be 0, because, you'd have no volume either, so x>0, so 0<x<2

anyway... so that'd be dv/dx... you can just run it through the quadratic formula to get the critical points, and run a first-derivative test on them, bearing in mind the range for "x", (0, 2)