Skip to content

Commit 01bb991

Browse files
committed
Add solution and test-cases for problem 2469
1 parent a01e89c commit 01bb991

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

leetcode/2401-2500/2469.Convert-the-Temperature/README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
# [2469.Convert the Temperature][title]
22

3-
> [!WARNING|style:flat]
4-
> This question is temporarily unanswered if you have good ideas. Welcome to [Create Pull Request PR](https://github.com/kylesliu/awesome-golang-algorithm)
5-
63
## Description
4+
You are given a non-negative floating point number rounded to two decimal places `celsius`, that denotes the **temperature in Celsius**.
5+
6+
You should convert Celsius into **Kelvin** and **Fahrenheit** and return it as an array `ans = [kelvin, fahrenheit]`.
7+
8+
Return the array `ans`. Answers within `10^-5` of the actual answer will be accepted.
9+
10+
**Note that**:
11+
12+
- `Kelvin = Celsius + 273.15`
13+
- `Fahrenheit = Celsius * 1.80 + 32.00`
714

815
**Example 1:**
916

1017
```
11-
Input: a = "11", b = "1"
12-
Output: "100"
18+
Input: celsius = 36.50
19+
Output: [309.65000,97.70000]
20+
Explanation: Temperature at 36.50 Celsius converted in Kelvin is 309.65 and converted in Fahrenheit is 97.70.
1321
```
1422

15-
## 题意
16-
> ...
17-
18-
## 题解
23+
**Example 2:**
1924

20-
### 思路1
21-
> ...
22-
Convert the Temperature
23-
```go
2425
```
25-
26+
Input: celsius = 122.11
27+
Output: [395.26000,251.79800]
28+
Explanation: Temperature at 122.11 Celsius converted in Kelvin is 395.26 and converted in Fahrenheit is 251.798.
29+
```
2630

2731
## 结语
2832

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package Solution
22

3-
func Solution(x bool) bool {
4-
return x
3+
func Solution(celsius float64) []float64 {
4+
return []float64{celsius + 273.15, celsius*1.8 + 32.00}
55
}

leetcode/2401-2500/2469.Convert-the-Temperature/Solution_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ func TestSolution(t *testing.T) {
1010
// 测试用例
1111
cases := []struct {
1212
name string
13-
inputs bool
14-
expect bool
13+
inputs float64
14+
expect []float64
1515
}{
16-
{"TestCase", true, true},
17-
{"TestCase", true, true},
18-
{"TestCase", false, false},
16+
{"TestCase1", 36.50, []float64{309.65000, 97.70000}},
17+
{"TestCase2", 122.11, []float64{395.26000, 251.79800}},
1918
}
2019

2120
// 开始测试
@@ -30,10 +29,10 @@ func TestSolution(t *testing.T) {
3029
}
3130
}
3231

33-
// 压力测试
32+
// 压力测试
3433
func BenchmarkSolution(b *testing.B) {
3534
}
3635

37-
// 使用案列
36+
// 使用案列
3837
func ExampleSolution() {
3938
}

0 commit comments

Comments
 (0)