{"id":120,"date":"2017-08-11T19:18:13","date_gmt":"2017-08-11T11:18:13","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=120"},"modified":"2018-11-27T16:19:38","modified_gmt":"2018-11-27T08:19:38","slug":"120","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=120","title":{"rendered":"69. Sqrt(x)"},"content":{"rendered":"<p>Implement\u00a0<code>int sqrt(int x)<\/code>.<\/p>\n<p>Compute and return the square root of\u00a0<em>x<\/em>, where\u00a0<em>x<\/em>\u00a0is guaranteed to be a non-negative integer.<\/p>\n<p>Since the return type\u00a0is an integer, the decimal digits are truncated and only the integer part of the result\u00a0is returned.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<pre><strong>Input:<\/strong> 4\r\n<strong>Output:<\/strong> 2\r\n<\/pre>\n<p><strong>Example 2:<\/strong><\/p>\n<pre><strong>Input:<\/strong> 8\r\n<strong>Output:<\/strong> 2\r\n<strong>Explanation:<\/strong> The square root of 8 is 2.82842..., and since \r\n\u00a0            the decimal part is truncated, 2 is returned.<\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\nclass Solution(object):\r\n    def mySqrt(self, x):\r\n        &quot;&quot;&quot;\r\n        :type x: int\r\n        :rtype: int\r\n        &quot;&quot;&quot;\r\n        return int(x**(1\/2.0))\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Implement\u00a0int sqrt(int x). Compute and return the squar<a href=\"https:\/\/www.ccagml.com\/?p=120\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">69. Sqrt(x)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/120"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=120"}],"version-history":[{"count":2,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/120\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}