In this paper, we prove tight sufficient conditions for traceability and Hamiltonicity of connected graphs with given minimum degree, in terms of Wiener index and Harary index. We also prove some result on Hamiltonicity of balanced bipartite graphs in the similar fashion. In two recent papers \cite{LDJ2016,LDJ2017}, Liu et al. corrected some previous work on traceability of connected graphs in terms of Wiener index and Harary index, respectively, such as \cite{HW2013,Y2013}. We generalize these results and give short and unified proofs. All results in this paper are best possible., Comment: 11 pages, finial version for publication in MATCH Commun. Math. Comput. Chem