# Left aligned equations in multiple lines

Normally I use the align tag and everything is aligned properly. But now for some reason the text isn't left aligned. The following is the code I normally use (code #1):

\begin{align*}
V[1] = A[1] & i = 1  \\
V[2] = \max \{ A[1], A[2] \} & i=2\\
V[i] = \max\{ V[i-1], V[i-2] + A[i] \} & i>2
\end{align*}


By reading some Q&A I found a method in which the text is properly left aligned, but the spacing is too great (code #2):

\begin{align*}
V[1] &= A[1] &  i = 1  \\
V[2] &= \max \{ A[1], A[2] \} & i=2\\
V[i] &= \max\{ V[i-1], V[i-2] + A[i] \} & i>2
\end{align*}


The following image shows the result of code#1 and code#2:

How do I reduce the spacing in code#2 ?
(I don't have access to the tags above \begin{document} or below \end{document}, so please don't offer solutions which involve them)

Try with alignat:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
V[1] &= A[1] &  i = 1 \\
V[2] &= \max \{ A[1], A[2] \} & i=2 \\
V[i] &= \max\{ V[i-1], V[i-2] + A[i] \} & i>2
\end{align*}

\begin{alignat*}{2}
V[1] &= A[1]                      & \quad i &= 1 \\
V[2] &= \max \{ A[1], A[2] \}           & i &= 2 \\
V[i] &= \max\{ V[i-1], V[i-2] + A[i] \} & i &> 2
\end{alignat*}

\end{document}