Skip to content

Commit

Permalink
solutions: 2469 - Convert the Temperature (Easy)
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Jan 27, 2024
1 parent 975996e commit a7ae81c
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions solutions/2400-2499/2469-convert-the-temperature-easy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
description: 'Author: @wingkwong | https://leetcode.com/problems/convert-the-temperature/'
tags: [Math]
---

# 2469 - Convert the Temperature (Easy)

## Problem Link

https://leetcode.com/problems/convert-the-temperature/

## Problem Statement

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: 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:**

```
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.
```

**Constraints:**

- `0 <= celsius <= 1000`

## Approach 1: Just do it

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

<Tabs>
<TabItem value="cpp" label="C++">
<SolutionAuthor name="@wingkwong"/>

```cpp
class Solution {
public:
vector<double> convertTemperature(double celsius) {
return {
celsius + 273.15,
celsius * 1.80 + 32.00
};
}
};
```
</TabItem>
</Tabs>

0 comments on commit a7ae81c

Please sign in to comment.