At local maximum or local minimum f ' (x) = 0
At x = -2 f '(x) =0 and it's value changes from positive to negative, that is mean we have local maximum.
At x= 1 f '(x) =0 and it's value changes from negative to positive, that is mean we have local minimum.