// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.sps;

import java.util.Collection;

public final class FindMeetingQuery {
  public Collection<TimeRange> query(Collection<Event> events, MeetingRequest request) {
    throw new UnsupportedOperationException("TODO: Implement this method.");
  }
}

@@ -606,17 +606,44 @@
 le.sps;%0A
+import java.util.ArrayList;
 %0A
-
 import j
@@ -795,16 +795,18 @@
 ) %7B%0A    
+//
 throw ne
@@ -870,14 +870,1447 @@
 hod.%22);%0A
+    ArrayList%3CTimeRange%3E answer = new ArrayList%3CTimeRange%3E();%0A%0A    int lastOkStartTime = -1;%0A    int intvervalLength = 0;%0A%0A    for (int hour = 0; hour %3C= 23; hour ++) %7B%0A        for (int minute = 0; minute %3C= 59; minute ++) %7B%0A            int start = hour * 60 + minute;%0A            TimeRange potential = TimeRange.fromStartDuration(start, (int)request.getDuration());%0A            boolean isOk = true;%0A%0A            if (!TimeRange.WHOLE_DAY.contains(potential)) break;%0A%0A            for (Event event : events) %7B%0A                if (event.getWhen().overlaps(potential)) %7B%0A                    for (String req_attendee : request.getAttendees()) %7B%0A                        if (event.getAttendees().contains(req_attendee))%0A                            isOk = false;%0A                    %7D%0A                %7D%0A            %7D%0A%0A            if (isOk) %7B%0A                if (lastOkStartTime == -1) %7B%0A                    lastOkStartTime = potential.start();%0A                    intvervalLength = 0;%0A                %7D%0A                intvervalLength ++;%0A            %7D else if (lastOkStartTime != -1) %7B%0A                answer.add(TimeRange.fromStartDuration(lastOkStartTime, intvervalLength-1 + (int)request.getDuration()));%0A                lastOkStartTime = -1;%0A            %7D%0A        %7D%0A    %7D%0A%0A    if(lastOkStartTime != -1)%0A        answer.add(TimeRange.fromStartDuration(lastOkStartTime, intvervalLength-1 + (int)request.getDuration()));%0A    return answer;%0A
   %7D%0A%7D%0A

Complete algorithm for FindMeetingQuery.