The first and the second Zagreb index of a graph, usually defined as the sum of the squares of degrees over all vertices and the sum of the products of degrees of edge endvertices over all edges, respectively, are tightly related to the numbers of walks of length two and three in the graph. We provide here a lower bound on the spectral radius of adjacency matrix A of graph in terms of its Zagreb indices, based on the properties of the least square approximation of the vector A2j with the vectors Aj and j, where j is the all-one vector. The bound is sharp for all graphs with two main eigenvalues, surpassing the range of sharpness of other bounds among connected graphs.