The global sections of the affine plane with the origin removed Consider the affine plane with the origin removed $U:=\mathbb{A}_k^2-\{(x,y)\}$.
First, This post asserts that the map $j^\sharp:\mathcal{O}(\mathbb{A}^2_k)\to \mathcal{O}(U)$ induced by the embedding $j:U\hookrightarrow \mathbb{A}^2_k$ is an isomorphism. I do not quite see why this follows from the fact that $\mathcal{O}(\mathbb{A}^2_k) \cong k[x,y]$. (This fact is computed in this lecture note, page 140.) I mean a a priori there can be many maps between $k[x,y] \to k[x,y]$ which might not be an isomorphism.
Second, the post also claims that if $U$ is affine, then $j^\sharp$ being an isomorphism would imply that $U \cong \mathbb A_{k}^{2}$, why is that? My thinking is that will imply the ring underlying both "affine" schemes will be isomorphic and so their spectrum is isomorphic(bijective as sets).
 A: For any integral scheme $X$ with generic point $\xi$,  open subset $U\subset X$, and point $x\in U\subset X$, there are canonical injections $\mathcal{O}_X(X)\to \mathcal{O}_X(U) \to \mathcal{O}_{X,x} \to \mathcal{O}_{X,\xi} = K(X)$, where $K(X)$ denotes the field of fractions of $X$. This means that $\mathcal{O}_X(U)\subset \bigcap_{x\in U} \mathcal{O}_{X,x}$ as subsets of $K(X)$.
In our particular case, we have $\bigcap_{x\in U} \mathcal{O}_{X,x} \subset \bigcap_{x\in U, \operatorname{ht} x=1} \mathcal{O}_{X,x} = \bigcap_{\mathfrak{p}\subset k[x,y], \operatorname{ht} \mathfrak{p}=1} k[x,y]_\mathfrak{p}$, and this last term is exactly $k[x,y]$ by algebraic Hartog's. So we have the following series of inclusions (after identifying everything with it's image inside $K(X)$): $$k[x,y]\subset \mathcal{O}_X(U) \subset  \bigcap_{x\in U} \mathcal{O}_{X,x} \subset \bigcap_{x\in U, \operatorname{codim} x=1} \mathcal{O}_{X,x} = \bigcap_{\mathfrak{p}\subset k[x,y], \operatorname{ht} \mathfrak{p}=1} k[x,y]_\mathfrak{p} = k[x,y]$$ and so $\mathcal{O}_X(U)=k[x,y]$.
The second question is a simple consequence of the fact that affine schemes and commutative rings are contravariantly equivalent categories: if $X$ and $Y$ are affine schemes, then $X\cong \operatorname{Spec} \mathcal{O}_X(X)$ and $Y\cong \operatorname{Spec} \mathcal{O}_Y(Y)$, so if $f:\mathcal{O}_X(X)\to\mathcal{O}_Y(Y)$ is an isomorphism, then $\operatorname{Spec} f$ induces an isomorphism $Y\to X$. (It is important to notice that "isomorphic as schemes" is much stronger than simply bijective as sets. All quasicompact schemes of dimension one over a field are bijective as sets, and all irreducible schemes of dimension one over a field are homeomorphic as topological spaces, but the classification of such objects is much more interesting than that.)
