You have couple of choice, but either way it will mean looping over the rows twice.
You can get the entire flex field as an array
$flex_field = get_field('content_builder');
Loop over this to create your in page navigation
You can also use the have_rows() method.
Or you can use a combination, doing it different for each. But in any case it will mean 2 loops. One to generate the navigation and another to generate the content.