Skip to content

2469. Convert the Temperature

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  vector<double> convertTemperature(double celsius) {
    return {celsius + 273.15, celsius * 1.8 + 32};
  }
};
1
2
3
4
5
class Solution {
  public double[] convertTemperature(double celsius) {
    return new double[] {celsius + 273.15, celsius * 1.8 + 32};
  }
}
1
2
3
class Solution:
  def convertTemperature(self, celsius: float) -> list[float]:
    return [celsius + 273.15, celsius * 1.8 + 32]