Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit272d168

Browse files
authored
Create Earliest Finish Time for Land and Water Rides I.java
1 parent1cd0212 commit272d168

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
classSolution {
2+
publicintearliestFinishTime(int[]landStartTime,int[]landDuration,int[]waterStartTime,int[]waterDuration) {
3+
intresult =Integer.MAX_VALUE;
4+
intn =landStartTime.length;
5+
intm =waterStartTime.length;
6+
intminEnd =Integer.MAX_VALUE;
7+
// Land ride first
8+
for (inti =0;i <n;i++) {
9+
minEnd =Math.min(minEnd,landStartTime[i] +landDuration[i]);
10+
}
11+
for (inti =0;i <m;i++) {
12+
result =Math.min(result,waterDuration[i] +Math.max(minEnd,waterStartTime[i]));
13+
}
14+
minEnd =Integer.MAX_VALUE;
15+
// Water ride first
16+
for (inti =0;i <m;i++) {
17+
minEnd =Math.min(minEnd,waterStartTime[i] +waterDuration[i]);
18+
}
19+
for (inti =0;i <n;i++) {
20+
result =Math.min(result,landDuration[i] +Math.max(minEnd,landStartTime[i]));
21+
}
22+
returnresult;
23+
}
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp