Skip to content

Commit 60622de

Browse files
committed
go: daily temperatures
1 parent 7a5249f commit 60622de

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

go/daily-temperatures.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
// https://leetcode.com/problems/daily-temperatures/
4+
func dailyTemperatures(temperatures []int) []int {
5+
var matrix [101][]int
6+
ans := make([]int, len(temperatures))
7+
for i, temp := range temperatures {
8+
matrix[temp] = append(matrix[temp], i)
9+
for j := 30; j < temp; j++ {
10+
if len(matrix[j]) > 0 {
11+
for x := 0; x < len(matrix[j]); x++ {
12+
ans[matrix[j][x]] = i - matrix[j][x]
13+
}
14+
matrix[j] = []int{}
15+
}
16+
}
17+
}
18+
return ans
19+
}

0 commit comments

Comments
 (0)