Finding the Sections of Signals that are the Most Similar
The best way to achieve this, to my knowledge, is a matched filter or cross-correlation. This will tell you not only how well $A$ and $B$ match but will also give you a time offset for it. Just make sure to normalized based on the energy of both signals so you aren't getting false positives if that's a major concern.
If you're looking for a more strict time match (the signal similarity needs to be in-time) then you only want to look at $R[0]$ where $R[n] = A[n] \star B[n]$.
Technically, cross-correlation of non Wide Sense Stationary signals is two-dimensional. So if you're interested in the particular time when the signals best match up with no offset, your process may look something like this over $Z$ trials.
$$
\begin{align}
R[n,m] &amp;= E\{A[n]B^*[m]\}\\
m &amp;= n\\
R[n] &amp;= E\{A[n]B^*[n]\}\\
R[n] &amp;= \frac{1}{Z}\sum_{\zeta=0}^{Z-1}{A_\zeta[n]B_\zeta[n]}
\end{align}
$$
If you clarify what sort of signals these are and what about their matching is important, I think it would help narrow down what solution would best fit.