{"id":9894,"date":"2022-11-22T20:05:27","date_gmt":"2022-11-23T04:05:27","guid":{"rendered":"https:\/\/zxi.mytechroad.com\/blog\/?p=9894"},"modified":"2022-11-22T20:05:46","modified_gmt":"2022-11-23T04:05:46","slug":"leetcode-2469-convert-the-temperature","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/math\/leetcode-2469-convert-the-temperature\/","title":{"rendered":"\u82b1\u82b1\u9171 LeetCode 2469. Convert the Temperature"},"content":{"rendered":"\n<p>You are given a non-negative floating point number rounded to two decimal places&nbsp;<code>celsius<\/code>, that denotes the&nbsp;<strong>temperature in Celsius<\/strong>.<\/p>\n\n\n\n<p>You should convert Celsius into&nbsp;<strong>Kelvin<\/strong>&nbsp;and&nbsp;<strong>Fahrenheit<\/strong>&nbsp;and return it as an array&nbsp;<code>ans = [kelvin, fahrenheit]<\/code>.<\/p>\n\n\n\n<p>Return&nbsp;<em>the array&nbsp;<code>ans<\/code>.&nbsp;<\/em>Answers within&nbsp;<code>10<sup>-5<\/sup><\/code>&nbsp;of the actual answer will be accepted.<\/p>\n\n\n\n<p><strong>Note that:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>Kelvin = Celsius + 273.15<\/code><\/li><li><code>Fahrenheit = Celsius * 1.80 + 32.00<\/code><\/li><\/ul>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> celsius = 36.50\n<strong>Output:<\/strong> [309.65000,97.70000]\n<strong>Explanation:<\/strong> Temperature at 36.50 Celsius converted in Kelvin is 309.65 and converted in Fahrenheit is 97.70.\n<\/pre>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted;crayon:false\"><strong>Input:<\/strong> celsius = 122.11\n<strong>Output:<\/strong> [395.26000,251.79800]\n<strong>Explanation:<\/strong> Temperature at 122.11 Celsius converted in Kelvin is 395.26 and converted in Fahrenheit is 251.798.\n<\/pre>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>0 &lt;= celsius &lt;= 1000<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Solution: Follow the formulas<\/strong><\/h2>\n\n\n\n<p>Time complexity: O(1)<br>Space complexity: O(1)<\/p>\n\n\n\n<div class=\"responsive-tabs\">\n<h2 class=\"tabtitle\">C++<\/h2>\n<div class=\"tabcontent\">\n\n<pre lang=\"c++\">\n\/\/ Author: Huahua\nclass Solution {\npublic:\n  vector<double> convertTemperature(double celsius) {\n    return {celsius + 273.15, celsius * 1.80 + 32.00};\n  }\n};\n<\/pre>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>You are given a non-negative floating point number rounded to two decimal places&nbsp;celsius, that denotes the&nbsp;temperature in Celsius. You should convert Celsius into&nbsp;Kelvin&nbsp;and&nbsp;Fahrenheit&nbsp;and return it&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[222,31],"class_list":["post-9894","post","type-post","status-publish","format-standard","hentry","category-math","tag-easy","tag-math","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/9894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=9894"}],"version-history":[{"count":2,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/9894\/revisions"}],"predecessor-version":[{"id":9896,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/9894\/revisions\/9896"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=9894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=9894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=9894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}