Example 2 Let $x_{i} \geqslant 0(i=1,2, \cdots, n)$, and $\sum_{i=1}^{n} x_{i}^{2}+2 \sum_{1 \leqslant k<j \leqslant n} \sqrt{\frac{k}{j}} x_{k} x_{j}=1$.
Find the maximum and minimum values of $f=\sum_{i=1}^{n} x_{i}$.
(2001, National High School Mathematics League Competition)
【Analysis】From the problem, we have
$$
\begin{array}{l}
f^{2}=\sum_{i=1}^{n} x_{i}^{2}+2 \sum_{1 \leqslant i0$, such that $z_{i}=c(\sqrt{i}-\sqrt{i-1})(1 \leqslant i \leqslant n)$.
Given $\sum_{i=1}^{n} z_{i}^{2}=1$, we find
$$
c=\frac{1}{\sqrt{\sum_{i=1}^{n}(\sqrt{i}-\sqrt{i-1})^{2}}},
$$

i.e., $z_{i}=\frac{\sqrt{i}-\sqrt{i-1}}{\sqrt{\sum_{i=1}^{n}(\sqrt{i}-\sqrt{i-1})^{2}}}(1 \leqslant i \leqslant n)$, at this point, $x_{i}=\frac{2 i-\sqrt{i(i-1)}-\sqrt{i(i+1)}}{\sqrt{\sum_{i=1}^{n}(\sqrt{i}-\sqrt{i-1})^{2}}}(i=1$, $2, \cdots, n)$.
Therefore, $f_{\max }=\sqrt{\sum_{i=1}^{n}(\sqrt{i}-\sqrt{i-1})^{2}}$.