Let $K=\mathbb{Q}[\sqrt{3}]$. I know the following generalization that is given as:
If $d\equiv 1\pmod{4}$, then $\mathcal{O}_{\mathbf{Q}[\sqrt{d}]}=\mathbf{Z}\left[\frac{-1+\sqrt{d}}{2}\right]$. Otherwise, $\mathcal{O}_{\mathbf{Q}[\sqrt{d}]}=\mathbf{Z}[\sqrt{d}]$.
However, I want to determine $\mathcal{O}_K$ where $K=\mathbb{Q}[\sqrt{3}]$. I will give the details of my work below and would like to learn how to finish my work and and is there any simpler or easier way to do it .
Now, since $\mathcal{O}_K\subseteq K$, elements of $O_K$ has the form $ a+b\sqrt3$. Now, if we say that $\alpha= a+b\sqrt3$, minimal polynomial of $\alpha$ is $f(X)=(X-\alpha)(X-\bar\alpha)$ which is $X^2-2aX+(a^2-3b^2)$. Since I took $\alpha$ from $\mathcal{O}_K$, the coefficients of $f$ must be integers. There are two cases:
$a\in \mathbb{Z}$:
This implies that $b \in \mathbb{Z}$ so that $\mathcal{O_K} \subseteq \mathbb{Z}[\sqrt{3}] $.
- $a \notin \mathbb{Z}$:
Then, since $2a \in \mathbb{Z}$, $a =\cfrac{u}{2}$ for some $u$ an odd integer. So, we have that $a^2 -3b^2 \in \mathbb{Z}$, thus, $4a^2-12b^2 \in \mathbb{Z}$. If $a \notin \mathbb{Z}$, $b\notin \mathbb{Z}$ too since otherwise $a$ must be in $\mathbb{Z}$ too by $a^2 -3b^2 \in \mathbb{Z}$.
Combining these two facts, we get $b= \cfrac{m}{n}$, $(m,n)=1$ and $\cfrac{12m^2}{n^2}\in \mathbb{Z}$. $(m,n) =1 \implies (m^2,n^2)=1 \implies n^2 |12 \implies n^2 | 4=2^2\implies n|2 \implies n=2$.
This is the point I stuck. I appreciate any help since I do not know how to move on or think after this point.
As you said $a+b \sqrt{3} \in \mathcal{O}_{\mathbb{Q}(\sqrt{3})},(a,b) \in \mathbb{Q}^2$ iff $X^2-2aX+(a^2-3b^2)\in\mathbb{Z}[X]$.
So that $n=2a\in \mathbb{Z}$,$m=2b \in \mathbb{Z}$ and $4 | n^2 - 3 m^2$ which is impossible if $n$ is odd. Thus $n$ is even and $a,b \in \mathbb{Z}$, ie. $\mathcal{O}_{\mathbb{Q}(\sqrt{3})}=\mathbb{Z}[\sqrt{3}]$