252.Meeting Rooms

Source: Internet
Author: User

    /** 252.Meeting Rooms * 2016-6-20 by Mingyang * Arrays.sort usage to be familiar with this problem and merge intervals very much like, we press the start time to put these inte     Once the rval are sorted, check to see if there is a conflict on the line.     * Conflicting definitions are when the start time is less than the latest end time.     * The last time before the end is not necessarily the last end time, so we have to take the maximum value when updating. */      Public Booleancanattendmeetings (interval[] intervals) {if(Intervals = =NULL|| Intervals.length = = 0)return true; Arrays.sort (intervals,NewComparator<interval>(){                 Public intCompare (Interval i1, Interval i2) {returnI1.start-I2.start;            }            }); intEnd = Intervals[0].end; //check each of the interval             for(inti = 1; i < intervals.length; i++){                //If the start time of the interval is less than the late end time, the return is False                if(Intervals[i].start < end)return false; End=Math.max (end, intervals[i].end); }            return true; }

252.Meeting Rooms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.