According to this article from PoliticsHome, the latest date on which a vote of no confidence could be held in order to have a general election before 31 October 2019 is 3 September, which could trigger an election on Thursday 24 October (see below for full analysis).
This assumes that any election would be on a Thursday, which is a matter of convention, not law. Also, this still only gives a week for the new parliament to meet and begin operation. In practice it typically takes longer than that - though for Brexit to be delayed or cancelled, whoever became PM after such an election could do the former, and probably the latter, without parliamentary approval.
The article points out that if a VoNC were to be held on 25 July, an election could be held on 19 or 26 September.
Full analysis from the above article:
The House of Commons returns from its summer recess on Tuesday 3 September. If MPs wanted to debate a statutory motion of no confidence that day, the Leader of the Opposition would have to table the motion before the House rose for summer recess (i.e. by Thursday 25 July). The vote would then be expected to take place in the afternoon or evening of Tuesday 3 September – the first day back after recess. If that motion passed, a 14-calendar day statutory period under the Fixed-term Parliaments Act 2011 would begin at midnight.
If, by the end of Tuesday 17 September no subsequent ‘motion of confidence’ had been passed in Her Majesty’s Government, an early general election would be triggered.
The date of an early election is set by Crown proclamation. The prime minister advises the Queen what the date should be. In this case, that proclamation could be made no earlier than Wednesday 18 September.
Parliament cannot be dissolved until after the proclamation is made. Dissolution must happen at the beginning of the 25th working day before polling day. The earliest Parliament could be dissolved would be Thursday 19 September, which would mean a polling day of Thursday 24 October had been set by proclamation.
Unless Article 50 is extended again, the UK unilaterally revokes Article 50, or a deal has been ratified by the UK and the EU, the UK leaves the EU by automatic operation of law at 11pm on 31 October 2019. The last potential Thursday polling day before exit day is 24 October.