Although it is not explicitly stated by either of the Gospel writers, it is generally accepted that Matthew presents the genealogy of Jesus through Joseph, and Luke Jesus’ genealogy through Mary. See Hendriksen’s imagined debate and his conclusion in favour of this position in his comments on Luke 3:23-38.
There are two other names in common to the two genealogies between David and Jesus: Shealtiel and Zerubbabel are found in both lists. See Hendriksen Survey p 136 for one possible explanation of this.