1. Cars and Gaps In Traffic
Given a 2 lane road with n positions and a
total number of m cars moving from left to
right, from a start position to a finish
position, determine the largest gap in
positions of all cars, without regard to lanes.
Example
n = 10
Answers
Answered by
0
static void solve(int m, List<Integer> start, List<Integer> finish) {
int i = 0;
int[] map = new int[m];
while (i < start.size()) {
for (int k = start.get(i)-1; k < finish.get(i); k++) {
map[k]=1;
}
i++;
}
System.out.println(c(map));
}
Attachments:
Similar questions