Answer
See below
Work Step by Step
Given $\frac{M_y-N_x}{M}=g(y)$
where $g(y)$ is only function of $y$
Multiply both sides by integrating factor $I(x)=e^{-\int g(y)dy}$
$\frac{\partial}{\partial x}(e^{-\int g(y)dy} N)=\frac{\partial}{\partial y}(e^{-\int g(y)dy}M)\\
\rightarrow e^{-\int g(y)dy}\frac{\partial N}{\partial x}+N\frac{\partial}{\partial x}e^{-\int g(y)dy}=M\frac{\partial}{\partial y}e^{-\int g(y)dy}+e^{-\int g(y)dy}\frac{\partial M}{\partial y}\\
\rightarrow e^{-\int g(y)dy}\frac{\partial N}{\partial x}+0=Me^{-\int g(y)dy}g(y)+e^{-\int g(y)dy}\frac{\partial M}{\partial y}\\
\rightarrow e^{-\int g(y)dy}\frac{\partial N}{\partial x}+0=Me^{-\int g(y)dy}g(y)(-\int g(y) dy)+e^{-\int g(y)dy}\frac{\partial M}{\partial y}\\
\rightarrow e^{-\int g(y)dy}\frac{\partial N}{\partial x}=Me^{-\int g(y)dy}(-g(y))+e^{-\int g(y)dy}\frac{\partial M}{\partial y}\\
\rightarrow e^{-\int g(y)dy}(\frac{\partial N}{\partial x}-\frac{\partial M}{\partial y})=-g(y)Me^{-\int g(y)dy}\\
\rightarrow e^{-\int g(y)dy}(\frac{\frac{\partial N}{\partial x}-\frac{\partial M}{\partial y}}{M})=-g(y)Me^{-\int g(y)dy}\\
\rightarrow \frac{M_y-N_x}{M}=g(y)$
Hence, $ e^{-\int g(y)dy}Mdx+ e^{-\int g(y)dy}Ndy=0$ is exact.