  Linear codes with complementary duals (abbreviated LCD) are linear codes
whose intersection with their dual is trivial. When they are binary, they play
an important role in armoring implementations against side-channel attacks and
fault injection attacks. Non-binary LCD codes in characteristic 2 can be
transformed into binary LCD codes by expansion. On the other hand, being
optimal codes, maximum distance separable codes (abbreviated MDS) have been of
much interest from many researchers due to their theoretical significant and
practical implications. However, little work has been done on LCD MDS codes. In
particular, determining the existence of $q$-ary $[n,k]$ LCD MDS codes for
various lengths $n$ and dimensions $k$ is a basic and interesting problem. In
this paper, we firstly study the problem of the existence of $q$-ary $[n,k]$
LCD MDS codes and completely solve it for the Euclidean case. More
specifically, we show that for $q>3$ there exists a $q$-ary $[n,k]$ Euclidean
LCD MDS code, where $0\le k \le n\le q+1$, or, $q=2^{m}$, $n=q+2$ and $k= 3
\text{or} q-1$. Secondly, we investigate several constructions of new Euclidean
and Hermitian LCD MDS codes. Our main techniques in constructing Euclidean and
Hermitian LCD MDS codes use some linear codes with small dimension or
codimension, self-orthogonal codes and generalized Reed-Solomon codes.
