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.
나의 풀이
1
2
3
4
5
6
7
8
9
10
|
/**
* @param {number} celsius
* @return {number[]}
*/
var convertTemperature = function(celsius) {
kelvin = celsius + 273.15
fahreheit = (celsius *1.8) + 32
return [kelvin, fahreheit]
};
|
cs |
'코딩 테스트 풀이 🛠' 카테고리의 다른 글
[프로그래머스] 인덱스 바꾸기 (0) | 2023.01.14 |
---|---|
[프로그래머스] 주사위의 개수 (0) | 2023.01.14 |
[Leet Code - eazy] 1929. Concatenation of Array (0) | 2023.01.14 |
[Leet Code - eazy] 1920. Build Array from Permutation (0) | 2023.01.14 |
[프로그래머스] 콜라츠 추측 (0) | 2023.01.11 |