How to find the index of the closest valid value given two boolean arrays