(N/A) Let the direction cosines of the vector $\vec{r}$ be $l, m, n$.
Given that the vector makes an angle of $\frac{\pi}{4}$ with the $y$-axis and $\frac{\pi}{2}$ with the $z$-axis.
Thus,$m = \cos(\frac{\pi}{4}) = \frac{1}{\sqrt{2}}$ and $n = \cos(\frac{\pi}{2}) = 0$.
We know that for any vector,$l^2 + m^2 + n^2 = 1$.
Substituting the values,$l^2 + (\frac{1}{\sqrt{2}})^2 + 0^2 = 1$.
$l^2 + \frac{1}{2} = 1 \Rightarrow l^2 = \frac{1}{2} \Rightarrow l = \pm \frac{1}{\sqrt{2}}$.
The unit vector $\hat{r}$ is given by $l\hat{i} + m\hat{j} + n\hat{k} = \pm \frac{1}{\sqrt{2}}\hat{i} + \frac{1}{\sqrt{2}}\hat{j} + 0\hat{k}$.
The required vector $\vec{r}$ is given by $|\vec{r}| \hat{r} = 3\sqrt{2} (\pm \frac{1}{\sqrt{2}}\hat{i} + \frac{1}{\sqrt{2}}\hat{j} + 0\hat{k})$.
Therefore,$\vec{r} = \pm 3\hat{i} + 3\hat{j}$.