import tensorflow as tf
from tensorflow.keras.layers import Dense, Flatten, Conv2D
from tensorflow.keras import Model
input_shape = (4, 28, 28, 3) int far = 0; int i = 0; int count = 0;
while (i < clips.size())
{
int nextFar = far;
while (i<clips.size() && clips[i][0]<=far)
{
nextFar = max(nextFar, clips[i][1]);
i++;
}
count++;
if (nextFar >= T)
return count;
else if (nextFar == far)
return -1;
far = nextFar;
}
return -1;
Make a list/vector of all sprinklers and sort them wrt the starting point of their span.
Now set the target at the start of the gallery and select the sprinkler which covers the target and reaches the furthest possible point (end of span).
Now, the target point moves one unit ahead of the end of span of the previously selected sprinkler. Repeat this process of selecting sprinklers till the complete gallery is covered.