Calculate time between 2 data of a sensor
Ok, yea...Please format this a little better (properly tabbed line spacing and such), and comments would go a long way to understanding this, because chances are people don't want to invest the time to decipher what's going on here without them. I'm not entirely sure what is going on here, but I'll just suggest what I would do in my understanding of the question, which is how to detect what the minimum and maximum value of the distance is and record the time at which each of these moments occurred. 

I would have a float value to store the maximum and minimum distance as well as their times, and simply on every iteration of the loop check if the position was greater than the previous maximum distance or shorter than the previous minimum distance. If either of those are true, set the maximum/minimum distance to the current position and set the maximum/minimum distance time to the current time, using millis(). There's no reason I can see, if I'm understanding this correctly for an array to store all the data, it's just taking up memory space from what I see.

Hope this helps a bit, and, if I'm totally off base, again I'll emphasize the utility of comments in readability. Hope this helps and good luck.