<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Math_&amp;_Geometry on Dmytro&#39;s Blog</title>
    <link>https://dmytros.blog/tags/math__geometry/</link>
    <description>Recent content in Math_&amp;_Geometry on Dmytro&#39;s Blog</description>
    <image>
      <title>Dmytro&#39;s Blog</title>
      <url>https://dmytros.blog/images/papermod-cover.png</url>
      <link>https://dmytros.blog/images/papermod-cover.png</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sat, 13 Jun 2026 10:51:19 +0300</lastBuildDate>
    <atom:link href="https://dmytros.blog/tags/math__geometry/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>LeetCode - 150 - Pow(x, n)</title>
      <link>https://dmytros.blog/posts/leetcode-150-pow-x-n/</link>
      <pubDate>Sat, 13 Jun 2026 10:51:19 +0300</pubDate>
      <guid>https://dmytros.blog/posts/leetcode-150-pow-x-n/</guid>
      <description>&lt;h3 id=&#34;the-problem&#34;&gt;The Problem&lt;/h3&gt;
&lt;p&gt;Implement &lt;a href=&#34;http://www.cplusplus.com/reference/valarray/pow/&#34;&gt;pow(x, n)&lt;/a&gt;, which calculates &lt;code&gt;x&lt;/code&gt; raised to the power &lt;code&gt;n&lt;/code&gt; (i.e., &lt;code&gt;xⁿ&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Input: x = 2.00000, n = 10
Output: 1024.00000
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Input: x = 2.10000, n = 3
Output: 9.26100
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Example 3:&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Input: x = 2.00000, n = -2
Output: 0.25000
Explanation: 2^-2 = 1/2^2 = 1/4 = 0.25
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-100.0 &amp;lt; x &amp;lt; 100.0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-2^31 &amp;lt;= n &amp;lt;= 2^31 - 1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;n&lt;/code&gt; is an integer.&lt;/li&gt;
&lt;li&gt;Either &lt;code&gt;x&lt;/code&gt; is not zero or &lt;code&gt;n &amp;gt; 0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-10^4 &amp;lt;= x^n &amp;lt;= 10^4&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;brute-force-solution&#34;&gt;Brute Force Solution&lt;/h3&gt;
&lt;h4 id=&#34;explanation&#34;&gt;Explanation&lt;/h4&gt;
&lt;p&gt;The brute force way to solve this problem without using built-in functions is to use a while loop and multiply the &lt;code&gt;x&lt;/code&gt; value &lt;code&gt;n&lt;/code&gt; times. The problem with this solution is that it will not pass on LeetCode because it takes &lt;code&gt;O(n)&lt;/code&gt; time.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
