zoukankan      html  css  js  c++  java
  • 252. Meeting Rooms

    import java.util.Arrays
    
    /**
     * 252. Meeting Rooms
     * (Locked by Leetcode)
     * https://www.lintcode.com/problem/meeting-rooms/description
     * Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei),
     * determine if a person could attend all meetings.
     * */
    
    class Interval(start: Int, end: Int) {
        var start = 0
        var end = 0
        init {
            this.start = start
            this.end = end
        }
    }
    
    class Solution {
        fun canAttendMeetings(intervals: List<Interval>?): Boolean {
            if (intervals == null) {
                return false
            }
            val size = intervals.size
            val starts = IntArray(size)
            val ends = IntArray(size)
            for (i in 0 until size) {
                starts[i] = intervals[i].start
                ends[i] = intervals[i].end
            }
            Arrays.sort(starts)
            Arrays.sort(ends)
            for (i in 1 until size) {
                if (ends[i - 1] > starts[i]) {
                    return false
                }
            }
            return true
        }
    }
  • 相关阅读:
    MySQL经典面试题--SQL语句
    awk命令
    mysql安装配置
    notepad++使用
    Xshell使用
    说明
    对 MMO 游戏的调研
    对 VR 项目开发流程的调研
    对 Unity 动态加载资源的调研
    对 Unity 太空射击游戏的实践
  • 原文地址:https://www.cnblogs.com/johnnyzhao/p/12387309.html
Copyright © 2011-2022 走看看