function [idx, pairs_checked, scan_indices] = two_ended_search_1(x, target)
pairs_checked = zeros(0,2);
scan_indices = zeros(1,0);
pairs_checked = zeros(maxIters, 2);
scan_indices = zeros(1, 2*maxIters);
pairCount = pairCount + 1;
pairs_checked(pairCount, :) = [L, R];
scanCount = scanCount + 1;
scan_indices(scanCount) = L;
scanCount = scanCount + 1;
scan_indices(scanCount) = R;
pairs_checked = pairs_checked(1:pairCount, :);
scan_indices = scan_indices(1:scanCount);
x = [5, 2, 3, 1, 9, 7, 9, 4, 8];
[idx, pairs_checked, scan_indices] = two_ended_search_1(x, target)
pairs_checked =
1 9
2 8
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
scan_indices =
1 9 2 8
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>