zoukankan      html  css  js  c++  java
  • 一个会议室最多安排几场宣讲


    import java.util.Arrays;

    /**
    * 一些项目要占用一个会议室宣讲,会议室不能同时容纳两个项目的宣讲
    * 提供每个项目的开始时间和结束时间,安排,返回最多的宣讲场次
    */
    public class BestArrange {

    public static int bestArrange(Program[] programs) {
    Arrays.sort(programs, (a, b) -> a.end - b.end);
    int timeLine = 0;
    int result = 0;
    for (int i = 0; i < programs.length; i++) {
    if (timeLine <= programs[i].start) {
    result++;
    timeLine = programs[i].end;
    }
    }
    return result;
    }

    /**
    * 项目会议
    */
    public class Program {

    // 开始时间
    public int start;

    // 结束时间
    public int end;

    public Program(int start, int end) {
    this.start = start;
    this.end = end;
    }

    }

    }

    /* 如有意见或建议,欢迎评论区留言;如发现代码有误,欢迎批评指正 */
  • 相关阅读:
    程序打包
    MFC AfxMessageBox默认标题修改
    Json
    agsXMPP
    xmpp
    afxcomctl32.h与afxcomctl32.inl报错
    jQuery使用
    EChart使用
    C++ tinyXML使用
    electron之Windows下使用 html js css 开发桌面应用程序
  • 原文地址:https://www.cnblogs.com/laydown/p/13060844.html
Copyright © 2011-2022 走看看