Skip to content

Add solution and test-cases for problem 2469 #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions leetcode/2401-2500/2469.Convert-the-Temperature/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# [2469.Convert the Temperature][title]

> [!WARNING|style:flat]
> This question is temporarily unanswered if you have good ideas. Welcome to [Create Pull Request PR](https://github.com/kylesliu/awesome-golang-algorithm)

## Description
You are given a non-negative floating point number rounded to two decimal places `celsius`, that denotes the **temperature in Celsius**.

You should convert Celsius into **Kelvin** and **Fahrenheit** and return it as an array `ans = [kelvin, fahrenheit]`.

Return the array `ans`. Answers within `10^-5` of the actual answer will be accepted.

**Note that**:

- `Kelvin = Celsius + 273.15`
- `Fahrenheit = Celsius * 1.80 + 32.00`

**Example 1:**

```
Input: a = "11", b = "1"
Output: "100"
Input: celsius = 36.50
Output: [309.65000,97.70000]
Explanation: Temperature at 36.50 Celsius converted in Kelvin is 309.65 and converted in Fahrenheit is 97.70.
```

## 题意
> ...

## 题解
**Example 2:**

### 思路1
> ...
Convert the Temperature
```go
```

Input: celsius = 122.11
Output: [395.26000,251.79800]
Explanation: Temperature at 122.11 Celsius converted in Kelvin is 395.26 and converted in Fahrenheit is 251.798.
```

## 结语

Expand Down
4 changes: 2 additions & 2 deletions leetcode/2401-2500/2469.Convert-the-Temperature/Solution.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Solution

func Solution(x bool) bool {
return x
func Solution(celsius float64) []float64 {
return []float64{celsius + 273.15, celsius*1.8 + 32.00}
}
13 changes: 6 additions & 7 deletions leetcode/2401-2500/2469.Convert-the-Temperature/Solution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ func TestSolution(t *testing.T) {
// 测试用例
cases := []struct {
name string
inputs bool
expect bool
inputs float64
expect []float64
}{
{"TestCase", true, true},
{"TestCase", true, true},
{"TestCase", false, false},
{"TestCase1", 36.50, []float64{309.65000, 97.70000}},
{"TestCase2", 122.11, []float64{395.26000, 251.79800}},
}

// 开始测试
Expand All @@ -30,10 +29,10 @@ func TestSolution(t *testing.T) {
}
}

// 压力测试
// 压力测试
func BenchmarkSolution(b *testing.B) {
}

// 使用案列
// 使用案列
func ExampleSolution() {
}
Loading