Determine the maximum of the expression

$$
x^{2} y+y^{2} z+z^{2} x-x^{2} z-y^{2} x-z^{2} y
$$

for $0 \leqslant x \leqslant 1,0 \leqslant y \leqslant 1,0 \leqslant z \leqslant 1$.
We can start by noting the following factorization:

$$
x^{2} y+y^{2} z+z^{2} x-x^{2} z-y^{2} x-z^{2} y=(x-y)(x-z)(y-z)
$$

By making a cyclic permutation of $(x, y, z)$, we can assume that $x \geqslant y, z$. We then observe that $(x-y)(x-y)(y-z)$ is maximal when $x=1$, so we seek the maximum
of $(1-y)(1-z)(y-z)$. For this quantity to be positive, we must have $y \geqslant z$. In this case, by the arithmetic-geometric mean inequality:

$$
(1-y)(1-z)(y-z) \leqslant(1-z) \cdot\left(\frac{(1-y)+(y-z)}{2}\right)^{2}=\frac{(1-z)^{3}}{4} \leqslant \frac{1}{4}
$$

Equality is achieved for $x=1, y=\frac{1}{2}, z=0$, so the value of the maximum sought is $\frac{1}{4}$.

Alternative solution: We have $(x-y)+(y-z)+(z-x)=0$, so one of the real numbers $x-y, y-z, z-x$ is positive. By making a cyclic permutation of $(x, y, z)$, we can assume that $y-z \geqslant 0$. The function $x \rightarrow x^{2} y+y^{2} z+z^{2} x-x^{2} z-y^{2} x-z^{2} y$ is then convex as a polynomial of the second degree with a leading coefficient equal to $y-z$. In particular, it reaches its maximum either at $x=0$ or at $x=1$.

If $x=0$, we are reduced to maximizing $y^{2} z-z^{2} y$, in which case the function $y \rightarrow y^{2} z-z^{2} y$ is again convex, so the maximum is reached for $y=0$ or $y=1$. For $y=0$, $y^{2} z-z^{2} y=0$, and for $y=1, y^{2} z-z^{2} y=z-z^{2}$, which is at most $\frac{1}{4}$ at $z=\frac{1}{2}$. In this case, the maximum is therefore $\frac{1}{4}$.

If $x=1$, we are reduced to maximizing $y-y^{2}+z^{2}-z+y^{2} z-z^{2} y$. Again, $z \rightarrow y-y^{2}+z^{2}-z+y^{2} z-z^{2} y$ is convex (as a polynomial of degree 2 with a leading coefficient $1-y \geqslant 0$), so it reaches its maximum either at $z=0$ or at $z=1$. We are again reduced to maximizing $y-y^{2}$, and we again find that the value of the maximum is $\frac{1}{4}$.