注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
记得之前看到某个面经里提到类似meeting room II,但是返回每个房间的具体的meeting。输入[0,30][5,10][15,35][32,40],输出 room1: [0,30][32,40], room2[5,10][15,35]之类的。
试着写了个方法,但是感觉比较麻烦,新建了个Room class。有bug,没想明白为什么错。。。编译的时候还会提示两个note,不知道是为什么。。。
Note: solution.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
MacBook-Pro:code loujunjie$ java solution
current firstEnd 30
creating a new room: 5,10;
current firstEnd 10
current firstEnd 35
creating a new room: 32,40;
5,10;15,35;
0,30;
32,40;
请问这题有什么简便的办法解么?谢谢!
import java.util.*;
public class solution {
public static void main(String[] args){
solution programm = new solution();
Interval[] intervals = new Interval[4];
intervals[0] = new Interval(0,30);
intervalng() {
String s = start + "," + end + ";";
return s;
}
}
class Room {
int end;
List<Interval> meetings;
Room(int end) {
this.end = end;
meetings = new ArrayList<Interval>();
}
public String toString() {
String s = " ";
for(Interval i : meetings) {
s+=i.toString();
}
return s;
}
}
|