<?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>Subarray Sum Equals K on Dmytro&#39;s Blog</title>
    <link>https://dmytros.blog/tags/subarray-sum-equals-k/</link>
    <description>Recent content in Subarray Sum Equals K 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 -- 0.147.1</generator>
    <language>en</language>
    <lastBuildDate>Tue, 25 Aug 2026 20:17:45 +0300</lastBuildDate>
    <atom:link href="https://dmytros.blog/tags/subarray-sum-equals-k/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>LeetCode - Subarray Sum Equals K</title>
      <link>https://dmytros.blog/posts/leetcode-subarray-sum-equals-k/</link>
      <pubDate>Tue, 25 Aug 2026 20:17:45 +0300</pubDate>
      <guid>https://dmytros.blog/posts/leetcode-subarray-sum-equals-k/</guid>
      <description>&lt;h3 id=&#34;the-problem&#34;&gt;The problem&lt;/h3&gt;
&lt;p&gt;Given an array of integers &lt;code&gt;nums&lt;/code&gt; and an integer &lt;code&gt;k&lt;/code&gt;, return &lt;em&gt;the total number of subarrays whose sum equals&lt;/em&gt; &lt;code&gt;k&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A subarray is a contiguous &lt;strong&gt;non-empty&lt;/strong&gt; sequence of elements within an array.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Input: nums = [1,1,1], k = 2
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Output: 2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Input: nums = [1,2,3], k = 3
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Output: 2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;1 &amp;lt;= nums.length &amp;lt;= 2 * 10^4&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-1000 &amp;lt;= nums[i] &amp;lt;= 1000&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-10^7 &amp;lt;= k &amp;lt;= 10^7&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;explanation&#34;&gt;Explanation&lt;/h4&gt;
&lt;p&gt;Even without visualization, you can see that each of the given examples has &lt;strong&gt;two&lt;/strong&gt; subarrays that can sum up to &lt;code&gt;k&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
