Longest common subsequence: Difference between revisions

Content deleted Content added
Petelomax (talk | contribs)
m changed l/r to match scs task (same output)
CNHume (talk | contribs)
The reverse iterator it2 now visits index2 values in descending order.
Line 389:
auto dq2 = *it1;
auto limit = threshold.end();
for (auto it2 = dq2.beginrbegin(); it2 != dq2.endrend(); it2++) {
// Each of the index1, index2 pairs considered here correspond to a match
auto index2 = *it2;
 
//
// Note: The index2reverse valuesiterator areit2 monotonicallyvisits decreasing,index2 whichvalues allowsin thedescending order,
// allowing thresholds to be updated in-place. Monotonicity allows astd::lower_bound() binaryis search,used
// implementedto hereperform bya std::lower_bound()binary search.
//
limit = lower_bound(threshold.begin(), limit, index2);
Line 410:
// divided by factors ranging from 2 up to 10 or more.
//
auto skip = next(it2) != dq2.endrend() &&
(limit == threshold.begin() || *prev(limit) < *next(it2));
if (skip) continue;
Line 463:
uint32_t index = 0;
for (const auto& it : s2)
indexes[it].push_frontpush_back(index++);
 
for (const auto& it : s1) {