-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrentHotel.go
62 lines (42 loc) · 1.2 KB
/
rentHotel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package programmers
import (
"strconv"
"strings"
)
func SolutionRentHotel(book_time [][]string) int {
maxResult := 1
var bookArray [25][61]int
for _, bookTime := range book_time {
startString := bookTime[0]
endString := bookTime[1]
//가공
startArr := strings.Split(startString, ":")
startHour, _ := strconv.Atoi(startArr[0])
startMin, _ := strconv.Atoi(startArr[1])
endArr := strings.Split(endString, ":")
endHour, _ := strconv.Atoi(endArr[0])
endMin, _ := strconv.Atoi(endArr[1])
gapHour := endHour - startHour
gapMin := endMin - startMin
totalGapMin := gapHour*60 + gapMin
// fmt.Println("시작시간:", startHour, startMin)
for i := 0; i < totalGapMin+10; i++ {
bookArray[startHour][startMin]++
// fmt.Println("bookArray추가", startHour, startMin, " 값:", bookArray[startHour][startMin])
if bookArray[startHour][startMin] > maxResult {
maxResult = bookArray[startHour][startMin]
// fmt.Println("시간겹쳐:", startHour, startMin)
}
startMin++
if startMin == 60 {
startMin = 0
startHour++
}
}
// fmt.Println("종료시간(청소 포함):", startHour, startMin)
// if startHour == 24 {
// break
// }
}
return maxResult
}