Now I am thinking they are the same person.
See
http://www.hope-of-israel.org/RahabtheHarlot.html for
some reasons why they might be different women.
But,
It was actually less than 440 years from Jericho to David. 1 Kings 6:1 says Solomon began building the Temple 480 years after the Exodus. This would be 440 years after Jericho fell. That was in Solomon's 4th year, and David reigned 40 years, starting at the age of 30. So the time from the
fall of Jericho to the birth of David is 480 - (40 wandering + 4th year of Solomon + 40 of David's reign + 30 yrs old) = 366. (
See https://hermeneutics.stackexchange.com/questions/29968/was-rahab-the-harlot-contemporary-with-salmon near the bottom of blog by "child of God")
This following seems to make the years fit nicely using Bible dates.
from
Greek Testament Commentary, Alford
"It has been imagined, on chronological grounds, that this Rachab must be a different person from Rahab of Jericho. But those very grounds completely tally with their identity. For Naashon (father of Salmon), prince of Judah (1Ch 2:10), offered his offering at the setting up of the tabernacle (Num 7:12) 39 years before the taking of Jericho. So that Salmon would be of mature age at or soon after that event; at which time Rahab was probably young, as her father and mother were living (Jos 6:23).
Nor is it any objection that Achan, the fourth in descent from Judah by Zara, is contemporary with Salmon, the sixth of the other branch: since the generations in the line of Zara average 69 years, and those in the line of Phares 49, both within the limits of probability. The difficulty of the interval of 366 years between Rahab and David does not belong to this passage only, but equally to Rth 4:21, Rth 4:22; and is by no means insuperable, especially when the extreme old age of Jesse, implied in 1Sa 17:12, is considered."
"I may add that, considering Rahab's father and mother were alive, the house would hardly be called the house of Rahab except on account of the character commonly assigned to her."