<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[The Coding Interview Gym: Interview Insights]]></title><description><![CDATA[Short breakdowns of coding interview concepts, mistakes and strategies. Each Insight is a quick read you can apply in your very next interview.]]></description><link>https://paulepps.substack.com/s/interview-insights</link><image><url>https://substackcdn.com/image/fetch/$s_!sUyV!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd0dab41-b251-4b04-8deb-bc6622d47f9c_1024x1024.png</url><title>The Coding Interview Gym: Interview Insights</title><link>https://paulepps.substack.com/s/interview-insights</link></image><generator>Substack</generator><lastBuildDate>Mon, 11 May 2026 16:31:03 GMT</lastBuildDate><atom:link href="https://paulepps.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Paul Epps]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[paulepps@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[paulepps@substack.com]]></itunes:email><itunes:name><![CDATA[Paul Epps]]></itunes:name></itunes:owner><itunes:author><![CDATA[Paul Epps]]></itunes:author><googleplay:owner><![CDATA[paulepps@substack.com]]></googleplay:owner><googleplay:email><![CDATA[paulepps@substack.com]]></googleplay:email><googleplay:author><![CDATA[Paul Epps]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Prefix Sums: The Hidden Pattern Behind 15 Array Interview Problems]]></title><description><![CDATA[Why do so many array interview questions reduce to the same three lines of math?]]></description><link>https://paulepps.substack.com/p/prefix-sums-the-hidden-pattern-behind</link><guid isPermaLink="false">https://paulepps.substack.com/p/prefix-sums-the-hidden-pattern-behind</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Wed, 06 May 2026 04:43:04 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080" width="5184" height="3888" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3888,&quot;width&quot;:5184,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;brown wooden number 10 on white table&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="brown wooden number 10 on white table" title="brown wooden number 10 on white table" srcset="https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1607018407033-7df1d72c3f6c?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cHJlZml4JTIwc3Vtc3xlbnwwfHx8fDE3NzgwMTg5NjJ8MA&amp;ixlib=rb-4.1.0&amp;q=80&amp;w=1080 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Photo by <a href="https://unsplash.com/@brett_jordan">Brett Jordan</a> on <a href="https://unsplash.com">Unsplash</a></figcaption></figure></div><p>Why do so many array interview questions reduce to the same three lines of math?</p><p>Because once you understand <strong>prefix</strong> <strong>sums</strong>, you can turn a whole class of &#8220;sum of this subarray&#8221; and &#8220;how many times does this condition happen&#8221; problems into mechanical O(1) queries after a single O(n) pass over the array.</p><p>In this post we&#8217;ll build the idea from scratch, then layer on:</p><ul><li><p>Deriving the prefix sum formula from first principles</p></li><li><p>Cumulative frequency maps (prefix sums over counts, not values)</p></li><li><p>2D prefix sums for matrices</p></li><li><p>Running sum vs. separate prefix array trade&#8209;offs</p></li><li><p>A simple Big O proof that you can reuse in interviews</p></li></ul><p>I&#8217;ll include TypeScript, Java, C#, and Python snippets so you can see the pattern in your favorite language.</p><div><hr></div><h2>1. Deriving prefix sums from first principles</h2><p>Imagine the most basic question:</p><blockquote><p>Given an array <code>nums</code>, answer many queries of the form: &#8220;What is the sum of <code>nums[l&#8230;r]</code>?&#8221;</p></blockquote><p>Brute force says: for each query, loop from <code>l</code> to <code>r</code> and add. That&#8217;s O(length of range) per query, which becomes O(n * q) for <code>q</code> queries.</p><p>The prefix trick is: do the work once, then reuse it.</p><p>Let <code>prefix[i]</code> be the sum of the first <code>i</code> elements:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;prefix[i] = nums[0] + \\dots + nums[i]&quot;,&quot;id&quot;:&quot;CIRUYZBEMG&quot;}" data-component-name="LatexBlockToDOM"></div><p>Then the sum of a subarray <code>nums[l&#8230;r]</code> is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;sum(l,r) = prefix[r] - prefix[l-1]&quot;,&quot;id&quot;:&quot;HEIJOXOLSH&quot;}" data-component-name="LatexBlockToDOM"></div><p>Why? Because <code>prefix[r]</code> includes everything from <code>0&#8230;r</code>, and <code>prefix[l-1]</code> includes everything from <code>0&#8230;l-1</code>, so subtracting cancels out the prefix and leaves <code>l&#8230;r</code>.</p><p>Corner case: when <code>l = 0</code>, we define </p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;sum(0, r) = prefix[r]&quot;,&quot;id&quot;:&quot;WPIGTGCNFH&quot;}" data-component-name="LatexBlockToDOM"></div><h2>Building the prefix array</h2><p>All four languages share the same core loop: &#8220;current prefix equals previous prefix plus current element.&#8221;</p><h2>TypeScript</h2><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;typescript&quot;,&quot;nodeId&quot;:&quot;ff710b6e-f814-4d29-b74e-91d1fb4e7f42&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-typescript">function buildPrefix(nums: number[]): number[] {
  const prefix = new Array(nums.length);
  let running = 0;
  for (let i = 0; i &lt; nums.length; i++) {
    running += nums[i];
    prefix[i] = running;
  }
  return prefix;
}

function rangeSum(prefix: number[], l: number, r: number): number {
  if (l === 0) return prefix[r];
  return prefix[r] - prefix[l - 1];
}</code></pre></div><h2>Java</h2><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;java&quot;,&quot;nodeId&quot;:&quot;20719cb2-932a-47d0-a155-06f1754d0527&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-java">int[] buildPrefix(int[] nums) {
    int n = nums.length;
    int[] prefix = new int[n];
    int running = 0;
    for (int i = 0; i &lt; n; i++) {
        running += nums[i];
        prefix[i] = running;
    }
    return prefix;
}

int rangeSum(int[] prefix, int l, int r) {
    if (l == 0) return prefix[r];
    return prefix[r] - prefix[l - 1];
}</code></pre></div><h2>C#</h2><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;csharp&quot;,&quot;nodeId&quot;:&quot;f85a52e7-cf73-4a0e-bc14-72352cde84f0&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-csharp">int[] BuildPrefix(int[] nums) {
    int n = nums.Length;
    int[] prefix = new int[n];
    int running = 0;
    for (int i = 0; i &lt; n; i++) {
        running += nums[i];
        prefix[i] = running;
    }
    return prefix;
}

int RangeSum(int[] prefix, int l, int r) {
    if (l == 0) return prefix[r];
    return prefix[r] - prefix[l - 1];
}</code></pre></div><h2>Python</h2><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:&quot;aaa4fd67-faf8-479a-abab-d82d63837796&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from typing import List

def build_prefix(nums: List[int]) -&gt; List[int]:
    prefix = []
    running = 0
    for x in nums:
        running += x
        prefix.append(running)
    return prefix

def range_sum(prefix: List[int], l: int, r: int) -&gt; int:
    if l == 0:
        return prefix[r]
    return prefix[r] - prefix[l - 1]</code></pre></div><p>Once students internalize &#8220;subarray sum = difference of two prefix sums,&#8221; a large set of LeetCode medium problems becomes immediately solvable.</p><div class="callout-block" data-callout="true"><p>The rest of the post is for paid subscribers and covers cumulative frequency maps, 2D prefix sums, running sums vs. separate prefix arrays, and a Big O proof of preprocessing and range query costs.</p><p>Includes code samples in Java, Python, C# and TypeScript.</p></div>
      <p>
          <a href="https://paulepps.substack.com/p/prefix-sums-the-hidden-pattern-behind">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Sliding Window Masterclass]]></title><description><![CDATA[The Pattern That Solves 20+ Interview Problems]]></description><link>https://paulepps.substack.com/p/sliding-window-masterclass</link><guid isPermaLink="false">https://paulepps.substack.com/p/sliding-window-masterclass</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Wed, 29 Apr 2026 06:31:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!QnX-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QnX-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QnX-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 424w, https://substackcdn.com/image/fetch/$s_!QnX-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 848w, https://substackcdn.com/image/fetch/$s_!QnX-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 1272w, https://substackcdn.com/image/fetch/$s_!QnX-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QnX-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png" width="800" height="450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:450,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:580525,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/195835354?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QnX-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 424w, https://substackcdn.com/image/fetch/$s_!QnX-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 848w, https://substackcdn.com/image/fetch/$s_!QnX-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 1272w, https://substackcdn.com/image/fetch/$s_!QnX-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce0bc987-3e7b-4414-bf03-5f3db32021d8_800x450.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The sliding window technique is one of the most powerful optimization patterns you&#8217;ll encounter in coding interviews. It transforms brute-force O(n&#178;) solutions into elegant O(n) algorithms by maintaining a &#8220;window&#8221; that moves across your data structure, processing elements as it expands and contracts.</p><h2>Why Sliding Window Matters</h2><p>This pattern appears in 20+ LeetCode problems and is frequently tested at FAANG companies. The core insight is simple: instead of recalculating results for every possible subarray from scratch, we maintain state as we slide through the data, adding new elements and removing old ones incrementally.</p><h2>Fixed vs Variable Window: The Two Flavors</h2><h3>Fixed-Length Windows</h3><p>Fixed-length sliding windows maintain a constant size k throughout execution. These problems explicitly state the window size and ask you to find optimal properties within all k-sized subarrays.</p><p><strong>When to use:</strong> Problems mentioning &#8220;k consecutive elements,&#8221; &#8220;subarray of size k,&#8221; or &#8220;fixed window of length k&#8221;</p><p><strong>Template structure:</strong></p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:&quot;487441fd-e8f0-4636-8727-2ad4b7247934&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">def fixed_window(arr, k):
    window_sum = 0
    max_sum = float('-inf')
    
    # Build initial window
    for i in range(k):
        window_sum += arr[i]
    
    max_sum = window_sum
    
    # Slide the window
    for i in range(k, len(arr)):
        window_sum += arr[i]      # Add new element
        window_sum -= arr[i - k]  # Remove old element
        max_sum = max(max_sum, window_sum)
    
    return max_sum</code></pre></div>
      <p>
          <a href="https://paulepps.substack.com/p/sliding-window-masterclass">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Two Sum: From O(n²) Brute to O(n) Hash Map ]]></title><description><![CDATA[And when interviewers want both]]></description><link>https://paulepps.substack.com/p/two-sum-from-on-brute-to-on-hash</link><guid isPermaLink="false">https://paulepps.substack.com/p/two-sum-from-on-brute-to-on-hash</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Wed, 22 Apr 2026 15:01:39 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!kz-j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kz-j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kz-j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 424w, https://substackcdn.com/image/fetch/$s_!kz-j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 848w, https://substackcdn.com/image/fetch/$s_!kz-j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 1272w, https://substackcdn.com/image/fetch/$s_!kz-j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kz-j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png" width="800" height="450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:450,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:757997,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/194865100?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kz-j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 424w, https://substackcdn.com/image/fetch/$s_!kz-j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 848w, https://substackcdn.com/image/fetch/$s_!kz-j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 1272w, https://substackcdn.com/image/fetch/$s_!kz-j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59e2085d-5f93-402b-8188-c38d6d02c3b2_800x450.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Two Sum is the FizzBuzz of modern coding interviews: if you can&#8217;t crush it, you probably won&#8217;t move on, but if you <em>only</em> memorize the hack, you&#8217;ll still underperform. This post walks from the naive O(n^2) nested-loop solution to the O(n) hash map pattern, then zooms out: when should you <em>prefer</em> the slow one, what tradeoffs are you actually making, and how do you adapt to common follow&#8209;ups like &#8220;what if the array is sorted?&#8221;</p><div><hr></div><h2>Problem recap</h2><blockquote><p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return the indices of the two numbers such that they add up to <code>target</code>.<br>You may assume exactly one solution and you may not use the same element twice.</p></blockquote><p>Think of it as: &#8220;find <em>i</em>, <em>j</em> with i&#8800;j such that <code>nums[i] + nums[j] == target</code>, and return <code>[i, j]</code>.&#8221;</p><div><hr></div><h2>Baseline: O(n&#178;) brute force</h2><p>The most straightforward way is to check every pair.</p><h2>Python brute force</h2><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:&quot;50d96cde-4a80-49ea-a45a-6ec6215e0181&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from typing import List

def two_sum_brute(nums: List[int], target: int) -&gt; List[int]:
    n = len(nums)
    for i in range(n):
        for j in range(i + 1, n):  # ensure i &lt; j, no reuse
            if nums[i] + nums[j] == target:
                return [i, j]</code></pre></div><h2>Java brute force</h2><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;java&quot;,&quot;nodeId&quot;:&quot;d0a17fda-15d0-45c0-98bb-f6e27fd50ac4&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-java">class Solution {
    public int[] twoSumBrute(int[] nums, int target) {
        int n = nums.length;
        for (int i = 0; i &lt; n; i++) {
            for (int j = i + 1; j &lt; n; j++) {    // j starts at i + 1
                if (nums[i] + nums[j] == target) {
                    return new int[]{i, j};
                }
            }
        }
    }
}</code></pre></div><h2>Big&#8209;O proof for brute force</h2><ul><li><p>Outer loop runs <em>n</em> times.</p></li><li><p>For each <code>i</code>, inner loop runs at most <em>n</em> - <em>i</em> - 1 times.</p></li><li><p>Total comparisons: </p></li></ul><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\sum_{i=0}^{n-1} (n - i - 1) = \\frac{n(n-1)}{2} = &#920;(n^2)&quot;,&quot;id&quot;:&quot;KXWHUBZFAA&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><ul><li><p>So time complexity is O(n^2); space is O(1) beyond the input and return value.</p></li></ul><p>This solution is slow for large inputs, but it&#8217;s <em>simple</em>, easy to reason about, and language&#8209;agnostic.</p><div><hr></div><h2>The O(n) hash map idea</h2>
      <p>
          <a href="https://paulepps.substack.com/p/two-sum-from-on-brute-to-on-hash">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[How Top FAANG Interviewers Rate Dynamic Programming Solutions]]></title><description><![CDATA[Common mistakes on the path from brute force to optimal DP]]></description><link>https://paulepps.substack.com/p/how-top-faang-interviewers-rate-dynamic</link><guid isPermaLink="false">https://paulepps.substack.com/p/how-top-faang-interviewers-rate-dynamic</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Wed, 15 Apr 2026 05:22:19 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!urfX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!urfX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!urfX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 424w, https://substackcdn.com/image/fetch/$s_!urfX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 848w, https://substackcdn.com/image/fetch/$s_!urfX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!urfX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!urfX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg" width="686" height="386" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:386,&quot;width&quot;:686,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:41267,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/194149392?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!urfX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 424w, https://substackcdn.com/image/fetch/$s_!urfX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 848w, https://substackcdn.com/image/fetch/$s_!urfX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!urfX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7986fc27-c77c-41f6-9687-eba921503e6f_686x386.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Overview</h2><p>The <a href="https://paulepps.substack.com/p/dynamic-programming-minimum-coins">Coin Change</a> problem is one of the most frequently asked dynamic programming questions at Google, Meta, Amazon, LinkedIn, Microsoft, Uber and Apple. But here&#8217;s the trap many candidates fall into: passing the brute-force recursion phase feels like a victory, when in reality, FAANG interviewers are just getting started on scoring you. The real evaluation kicks in <em>after</em> you&#8217;ve described the naive solution. This post breaks down exactly how interviewers score DP solutions and catalogs the most damaging mistakes candidates make on the path from brute force to optimal DP.</p><div><hr></div><h2>How FAANG Interviewers Actually Score You</h2><h3>The Four Rubric Dimensions</h3><p>Across FAANG companies, coding interview rubrics consistently evaluate four dimensions:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lrjy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lrjy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 424w, https://substackcdn.com/image/fetch/$s_!lrjy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 848w, https://substackcdn.com/image/fetch/$s_!lrjy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 1272w, https://substackcdn.com/image/fetch/$s_!lrjy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lrjy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png" width="1392" height="526" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1838c24c-4b04-4060-9274-967e359a953a_1392x526.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:526,&quot;width&quot;:1392,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:81662,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/194149392?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lrjy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 424w, https://substackcdn.com/image/fetch/$s_!lrjy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 848w, https://substackcdn.com/image/fetch/$s_!lrjy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 1272w, https://substackcdn.com/image/fetch/$s_!lrjy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1838c24c-4b04-4060-9274-967e359a953a_1392x526.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Each of these is scored independently, typically on a Strong Hire / Hire / No Hire / Strong No Hire scale. A candidate who finishes coding but can&#8217;t explain their decisions can be rated &#8220;No Hire&#8221; even with a working solution.</p><h3>Process Over Perfection</h3><p>FAANG interviewers are explicitly trained to measure <em>how</em> you think, not just <em>what</em> you produce. A technically imperfect solution with clear, structured reasoning can still earn a Strong Hire; a perfectly coded solution delivered silently will often earn a No Hire. Interviewers are told: <em>&#8221;You&#8217;re not hiring someone to ace an interview. You&#8217;re hiring someone you&#8217;d trust to design systems in ambiguity.&#8221;</em></p><p>The rubric also rewards candidates who demonstrate <strong>signal consistency</strong>: showing strength across multiple dimensions throughout the session, not just one moment of brilliance.</p><div><hr></div><h2>The Brute-Force Trap</h2><p>Getting through brute force recursion is a baseline, not a milestone. Interviewers at top tech companies treat the recursive solution as a communication exercise, not a problem-solving accomplishment. They&#8217;re watching whether you can:</p><ul><li><p>Correctly identify the problem as having <strong>overlapping subproblems</strong> (not just unbounded recursion)</p></li><li><p>Spontaneously articulate <em>why</em> it&#8217;s exponential: O(c^n) where c = coin count and n = target amount</p></li><li><p>Volunteer to optimize <em>before</em> being prompted</p></li></ul><p>Candidates who wait to be asked &#8220;can you do better?&#8221; before mentioning memoization lose points on problem-solving proactiveness</p><div><hr></div><h2>7 Critical Mistakes After Brute Force</h2><h3>Mistake 1: Greedy Without Proof</h3><p>This is the most damaging single error in the entire Coin Change interview. Many candidates, upon seeing an optimization problem, immediately default to a greedy strategy: pick the largest coin first, repeat. This works for canonical coin systems like USD (1, 5, 10, 25), but fails for arbitrary denominations.</p><p>Classic counterexample that interviewers use: coins = [1, 3, 4], amount = 6. Greedy picks 4+1+1 = 3 coins; the optimal answer is 3+3 = 2 coins. Another: coins = [1, 20, 25], amount = 40. Greedy picks 25+15&#215;1 = 16 coins; DP finds 20+20 = 2 coins.</p><p><strong>What interviewers look for instead:</strong> A sharp candidate will verbally run a counterexample test before committing to any strategy, then explicitly state: &#8220;Greedy fails here because the coin system isn&#8217;t canonical, so I need DP.&#8221; Failing to prove greedy correctness is a red flag for weak algorithmic reasoning.</p><h3>Mistake 2: Wrong DP Array Initialization</h3><p>This is the most common *implementation* error even after candidates correctly identify the DP approach. The mistake: initializing the dp array with all zeros instead of infinity (or <code>float(&#8217;inf&#8217;)</code> in Python).</p><p>Initializing with zeros incorrectly marks every amount as reachable with 0 coins, which corrupts the recurrence relation. The correct initialization is:</p><ul><li><p><code>dp[0] = 0</code> &#8212; zero coins needed to make amount zero (base case)</p></li><li><p><code>dp[i] = infinity</code> for all i &gt; 0 &#8212; all other amounts start as &#8220;impossible&#8221;</p></li></ul><p>Then after the DP loop, if <code>dp[amount]</code> is still infinity, return -1. Candidates who initialize with zeros and then forget to return -1 for impossible inputs fail on both initialization and edge-case handling.</p><h3>Mistake 3: Forgetting the Impossible Case (-1 Return)</h3><p>A surprising number of candidates who solve the DP correctly forget to handle the case where the target amount cannot be formed at all. For example, coins =  [2, 5] and amount = 3 has no solution, and the expected return value is -1.</p><p>Interviewers at FAANG expect this to be handled proactively, not after a prompt. Failing to mention or test impossible inputs costs points on both the Problem Solving dimension (missed constraint) and the Testing dimension (incomplete edge case coverage.</p><h3>Mistake 4: Inability to Articulate the Recurrence Relation</h3><p>This is where many candidates &#8212; even those with correct code &#8212; lose significant points. The DP recurrence for minimum coins is:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;dp[i] = \\min_{c \\in \\text{coins},\\ c \\le i}(dp[i - c] + 1)&quot;,&quot;id&quot;:&quot;DZWOGZASMV&quot;}" data-component-name="LatexBlockToDOM"></div><p>Candidates who &#8220;know the code&#8221; but can&#8217;t explain <em>why</em> this recurrence is correct &#8212; specifically, <em>why</em> using coin c and then solving for (amount &#8722; c) yields the correct minimum &#8212; fail the Communication and Problem Solving rubric dimensions. Interviewers are trained to ask follow-ups like: &#8220;Walk me through why <code>dp[i - coin] + 1</code> is the correct transition.&#8221;</p><h3>Mistake 5: Not Explaining Time and Space Complexity Unprompted</h3><p>Once the DP solution is coded, strong candidates immediately state:</p><ul><li><p><strong>Time complexity:</strong> O(amount &#215; number of coins)</p></li><li><p><strong>Space complexity:</strong> O(amount)</p></li></ul><p>Candidates who wait to be asked, or who give incorrect complexity analysis (e.g., confusing exponential brute-force with DP complexity), lose points on the Problem Solving dimension, specifically on the &#8220;determined time and space complexity accurately&#8221; rubric signal. This is a near-universal failure pattern across DP problems.</p><h3>Mistake 6: Jumping Straight to Bottom-Up Without Explaining Top-Down First</h3><p>FAANG interviewers reward candidates who can show the full DP thought ladder: brute force &#8594; memoized recursion (top-down) &#8594; tabulation (bottom-up). Jumping straight to a bottom-up DP table without acknowledging the top-down approach misses the opportunity to demonstrate that you understand <em>why</em> DP works &#8212; <a href="https://www.geeksforgeeks.org/dsa/overlapping-subproblems-property-in-dynamic-programming-dp-1/">overlapping subproblems and optimal substructure</a> &#8212; not just how to implement it.</p><p>From a Reddit thread of FAANG candidates: <em>&#8221;People who start with tabulation are bound to fail unless they are very experienced in solving DP problems. Recursion is the most important DSA concept.&#8221;</em> The top-down path makes the subproblem structure visible and is easier for interviewers to assess your reasoning.</p><h3>Mistake 7: Silent Coding and Poor Recovery from Hints</h3><p>Two behavioral patterns that destroy scores even when code is correct:</p><ol><li><p><strong>Silent coding:</strong> Stopping verbal communication once implementation starts. FAANG interviewers score Communication throughout the session. Coding silently for more than 30-45 seconds without narrating your logic signals poor collaboration potential.</p></li><li><p><strong>Defensive reaction to hints:</strong> When an interviewer nudges (&#8221;what happens if no combination is possible?&#8221;), top candidates treat it as a collaborative prompt and integrate it gracefully. Candidates who become flustered, defensive, or who restart entirely lose points. </p></li></ol><div><hr></div><h2>What a Strong Hire Solution Looks Like</h2><p>A candidate rated Strong Hire on Coin Change will typically do all of the following. These apply to DP problems in general, with some variation in the details.</p><ol><li><p><strong>Clarify before coding:</strong> confirm unbounded coin use, clarify the return value for impossible cases, restate constraints</p></li><li><p><strong>Sketch brute force first: </strong>name the exponential complexity, identify overlapping subproblems</p></li><li><p><strong>Run a greedy counterexample:</strong> explicitly reject greedy before proposing DP</p></li><li><p><strong>Explain the DP state and transition:</strong> before writing code</p></li><li><p><strong>Implement correctly:</strong> including <code>dp = [infinity] * (amount + 1)</code> and <code>dp[0] = 0</code> </p></li><li><p><strong>Return -1 for impossible cases:</strong> proactively, without being prompted</p></li><li><p><strong>State complexity immediately:</strong> O(amount &#215; n) time, O(amount) space</p></li><li><p><strong>Test with edge cases:</strong> amount = 0, impossible amount (e.g., coins=[2, 5], amount=3), single-coin input</p></li></ol><div><hr></div><h2>The Scoring Reality: Partial Credit Is Real</h2><p>One underappreciated fact: FAANG rubrics are designed to award partial credit. A candidate who doesn&#8217;t finish the optimal solution but demonstrates deep reasoning on the brute-force-to-DP transition, correctly names the recurrence, explains complexity, and tests edge cases can still receive a &#8220;Leaning Hire&#8221; or even &#8220;Hire&#8221;. Conversely, a candidate who silently produces working code with no explanation can be rated &#8220;Leaning No Hire&#8221; on Communication and Problem Solving even if the solution is correct.</p><p>A technically perfect solution with poor communication scores low, and a partial solution with clear structure can still pass if the reasoning shows growth potential.</p><div><hr></div><h2>Key Takeaways</h2><ul><li><p><strong>Greedy without proof is the #1 killer:</strong> Interviewers deliberately use non-canonical coin sets to catch candidates who assume &#8220;pick the largest coin&#8221; works.</p></li><li><p><strong>Initialization is a trap:</strong> Setting <code>dp</code> to all zeros instead of <code>infinity</code> is the most common <em>implementation</em> error after correctly identifying DP</p></li><li><p><strong>Silent coding scores a No Hire:</strong> FAANG rubrics score Communication throughout the session, not just at the start</p></li><li><p><strong>Partial credit is real:</strong> A candidate who doesn&#8217;t finish but clearly explains the recurrence, complexity, and edge cases can still get a Hire.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">The Coding Interview Gym publishes weekly coding challenges, challenge reviews, and interview tips for engineers preparing for FAANG and top-tier interviews. If you&#8217;re not subscribed yet, join here:</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><p><em>&#169; The Coding Interview Gym | paulepps.substack.com</em></p>]]></content:encoded></item><item><title><![CDATA[Why Behavioral Interview Prep Frameworks Succeed or Fail for Software Engineers at FAANG Companies]]></title><description><![CDATA[Key patterns from interviewer insights]]></description><link>https://paulepps.substack.com/p/why-behavioral-interview-prep-frameworks</link><guid isPermaLink="false">https://paulepps.substack.com/p/why-behavioral-interview-prep-frameworks</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Wed, 08 Apr 2026 04:55:54 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Pq0R!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pq0R!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pq0R!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 424w, https://substackcdn.com/image/fetch/$s_!Pq0R!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 848w, https://substackcdn.com/image/fetch/$s_!Pq0R!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 1272w, https://substackcdn.com/image/fetch/$s_!Pq0R!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pq0R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png" width="800" height="450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:450,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:533432,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/192621774?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Pq0R!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 424w, https://substackcdn.com/image/fetch/$s_!Pq0R!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 848w, https://substackcdn.com/image/fetch/$s_!Pq0R!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 1272w, https://substackcdn.com/image/fetch/$s_!Pq0R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffac4a441-41a6-4a4d-9a44-c88e3c9d16a2_800x450.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Summary</h2><p>The behavioral interview is the round where <strong>technically strong software engineers fail most often</strong>, not due to lack of experience, but <strong>because they have never practiced converting real work into a clear, structured spoken narrative.</strong> FAANG companies use structured rubrics, calibrated by seniority level, that evaluate specific behavioral signals, not general storytelling ability. Frameworks like STAR succeed when candidates decode the company&#8217;s actual rubric and build versatile, level-appropriate stories; they fail when candidates treat them as scripts for memorized answers rather than tools for presenting evidence.</p><p>If you&#8217;d like a copy of the article in PDF format, you can download it using the link below.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">The Coding Interview Gym is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="file-embed-wrapper" data-component-name="FileToDOM"><div class="file-embed-container-reader"><div class="file-embed-container-top"><image class="file-embed-thumbnail-default" src="https://substackcdn.com/image/fetch/$s_!0Cy0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack.com%2Fimg%2Fattachment_icon.svg"></image><div class="file-embed-details"><div class="file-embed-details-h1">Why Behavioral Interview Prep Frameworks Succeed Or Fail At Faang Companies</div><div class="file-embed-details-h2">305KB &#8729; PDF file</div></div><a class="file-embed-button wide" href="https://paulepps.substack.com/api/v1/file/13ba9458-6989-4b14-a022-c98d9b9207ac.pdf"><span class="file-embed-button-text">Download</span></a></div><a class="file-embed-button narrow" href="https://paulepps.substack.com/api/v1/file/13ba9458-6989-4b14-a022-c98d9b9207ac.pdf"><span class="file-embed-button-text">Download</span></a></div></div><div><hr></div><h2>How Each FAANG Company Actually Evaluates Behavioral Answers</h2><p>Understanding that each company has a distinct rubric is <strong>the single most important insight for preparation</strong>. A good story for Amazon may not satisfy Google&#8217;s expectations, and vice versa.</p><h3>Meta &#8212; The &#8220;Jedi&#8221; Round</h3><p>Meta&#8217;s dedicated behavioral round, internally called the &#8220;Jedi&#8221; interview, typically runs 45 minutes and probes <strong>eight focus areas</strong>: motivation, proactivity, ability to work in unstructured environments, perseverance, conflict resolution, empathy, growth and communication. The interviewer is simultaneously using these signals to calibrate the candidate&#8217;s seniority level: IC4 (junior), IC5 (senior), or IC6 (staff).</p><p>The seniority calibration hinges on the <strong>scope of the story</strong>, not the storytelling quality alone. Meta explicitly maps impact scope to levels:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bWoc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bWoc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 424w, https://substackcdn.com/image/fetch/$s_!bWoc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 848w, https://substackcdn.com/image/fetch/$s_!bWoc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 1272w, https://substackcdn.com/image/fetch/$s_!bWoc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bWoc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png" width="871" height="487" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:487,&quot;width&quot;:871,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:93054,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/192621774?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bWoc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 424w, https://substackcdn.com/image/fetch/$s_!bWoc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 848w, https://substackcdn.com/image/fetch/$s_!bWoc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 1272w, https://substackcdn.com/image/fetch/$s_!bWoc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52bd6424-3349-43ea-b72a-d339cc2db8d3_871x487.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>It is often on the behavioral interview alone that a candidate is down-leveled during deliberations. Candidates who tell the right story but at the wrong scope lose the level, and sometimes lose the offer entirely.</p><p></p><p>Meta&#8217;s three key Jedi signals are <strong>self-awareness</strong> (do you own your failures, or blame the team?), <strong>ambiguity navigation</strong> (can you execute without defined requirements?), and <strong>pacing</strong> (do you optimize for iterative shipping, or get paralyzed by perfectionism?).</p><h3>Amazon &#8212; The Leadership Principles Engine</h3><p><strong>Amazon is the most behaviorally rigorous FAANG company</strong>. Behavioral questions appear throughout the entire interview loop, from recruiter screen to final on-site, and every question is designed to map onto one or more of Amazon&#8217;s 16 Leadership Principles (LPs). The 16 LPs include Customer Obsession, Ownership, Invent and Simplify, Are Right A Lot, Bias for Action, Hire and Develop the Best, Insist on the Highest Standards, Think Big, Earn Trust, Dive Deep, Have Backbone, Disagree and Commit, Deliver Results, and others.</p><p>A critical but often missed element is the &#8220;Bar Raiser,&#8221; an independent interviewer who can veto a hire regardless of other interviewers&#8217; recommendations. The Bar Raiser calibrates whether the candidate truly raises Amazon&#8217;s bar, not just whether they performed adequately.</p><p>The most common way candidates fail Amazon behavioral rounds is by not handling follow-up questions: Candidate tells some story about how they saved the day from some issue in prod. Interviewer says &#8220;awesome, and what did you do to prevent it from happening again?&#8221; If the candidate doesn&#8217;t have a good answer to the follow-up, they just failed that interview no matter how well they solve the coding problems. Amazon expects a postmortem mindset: systematic prevention, not just incident response.</p><h3>Google &#8212; Googleyness and Leadership</h3><p>Google evaluates candidates on four attributes: general cognitive ability, leadership, role-related knowledge, and &#8220;Googleyness.&#8221; Googleyness is Google&#8217;s term for the cultural traits that predict success in its collaborative, fast-moving environment. Specifically, Google interviewers assess comfort with ambiguity, bias toward action, collaborative mindset, and intellectual humility.</p><p>Candidates can expect 2-4 behavioral questions per interview round; rounds focused specifically on Googleyness and leadership may have 5-6 questions, each with follow-ups. Google looks for emergent leadership: evidence of influence through persuasion, data, and collaboration rather than through hierarchy or formal authority.</p><p>The Googleyness dimension that catches candidates off guard is <strong>intellectual humility</strong>, i.e., telling a story where you changed your mind based on evidence from someone more junior, or where you genuinely learned from failure without minimizing it.</p><h3>Apple &#8212; 67 Competencies, Contextual Fit</h3><p>Apple draws from a library of 67 behavioral competencies and will assess 6&#8211;16 of them during a hiring loop. Behavioral interviewing accounts for approximately one-third of the Apple interview process. The specific competencies assessed depend on the role, making generic preparation less effective than role-specific mapping.</p><p><strong>Apple emphasizes product thinking, creative problem-solving, and deep collaboration more than the other FAANG companies.</strong> Strong answers showcase ownership (initiative taken even in ambiguous situations), measurable impact (metrics, user feedback, or stakeholder outcomes), creativity (challenging assumptions), and cross-functional execution.</p><h3>Netflix &#8212; The Culture Memo as Rubric</h3><p>Netflix&#8217;s culture interview is not primarily a storytelling exercise. It is a high-signal behavioral screen focused on decision-making quality, ownership, candor, and impact in a &#8220;freedom and responsibility&#8221; environment. Interviewers are not checking for personality match; they are validating whether a candidate&#8217;s working style fits an environment with high autonomy, fast tradeoffs, direct feedback, and very strong expectations for results.</p><p><strong>A useful mental model for Netflix:</strong> (1) Context clarity: can you frame ambiguity, constraints, and stakeholders clearly? (2) Judgment: how did you choose a path, what risks did you take, and why? (3) Accountability: what did you own end-to-end and what did you learn? (4) High impact with integrity: measurable outcomes, customer focus, and trust-building behaviors like transparency and candor. <strong>Netflix expects candidates to have read and internalized the Netflix Culture Memo before the interview.</strong></p><div><hr></div><h2>Why Behavioral Prep Frameworks Fail: 10 Recurring Patterns</h2><h3>Pattern 1: Type Mismatch &#8212; Returning a System Diagram Instead of a Story</h3><p>When asked about a conflict, you explain the architecture. The interviewer wanted <code>Story&lt;PersonalDecision&gt;</code> and you returned <code>TechnicalOverview&lt;SystemDesign&gt;</code>. Engineers instinctively default to technical explanations. Interviewers are explicitly looking for personal decision-making, interpersonal dynamics, and judgment, not architecture walkthroughs. This type mismatch is the most frequent failure mode for engineers new to behavioral prep.</p><h3>Pattern 2: Never Running the Code &#8212; No Verbal Practice</h3><p>There is a massive difference between reading code and executing it. Same with behavioral answers. In your head, the story compiles cleanly. Out loud, you hit null pointers everywhere. Most candidates who fail behavioral rounds have mentally rehearsed their stories but never spoken them aloud under simulated pressure. Verbal delivery reveals gaps: unclear starting points, excessive context or results that get &#8220;garbage-collected&#8221; before the interviewer hears them.</p><h3>Pattern 3: The &#8220;We&#8221; Problem &#8212; Collective Pronouns Hide Individual Contribution</h3><p>Answers filled with &#8220;we identified the issue,&#8221; &#8220;we implemented the solution,&#8221; and &#8220;we shipped it on time&#8221; provide no signal about what the candidate actually did. Interviewers cannot assess whether the candidate led the charge or attended meetings. The fix is deliberate use of &#8220;I&#8221; statements with specific attribution: &#8220;While my teammate handled the frontend, I refactored the API endpoints and proposed the caching strategy.&#8221;</p><h3>Pattern 4: Only Handling the Happy Path</h3><p>Follow-ups are the edge cases of behavioral interviews. They are where the real evaluation happens. If you only test the happy path, you will fail in production. Candidates who prepare for <code>tellMeAboutLeadership()</code> but not for <code>whyDidntYouEscalateSooner()</code> or <code>whatWouldYouChangeNow()</code> collapse under probing. This is especially critical at Amazon, where Bar Raiser follow-ups are designed specifically to pressure-test stories.</p><h3>Pattern 5: Level Mismatch &#8212; Scoping Stories Too Small</h3><p>Senior and staff candidates frequently tell stories appropriate for a mid-level engineer. A senior engineer describing a conflict between two coworkers on an implementation detail &#8212; a perfectly valid E4 answer &#8212; signals E3 scope at the E5 bar. The scope of stakeholders, teams involved, and business impact all signal level. An E5 answer requires multi-team involvement and org-level impact; an E6 answer requires cross-org strategic influence and multi-team coordination.</p><h3>Pattern 6: Memorizing Questions Instead of Building Versatile Stories</h3><p>A mental spreadsheet mapping specific stories to specific questions fails because behavioral questions are incredibly varied. When the actual question differs slightly from the memorized version, candidates stall, give mismatched answers or sound scripted. Preparation should focus on building 8&#8211;12 versatile &#8220;story fixtures&#8221; &#8212; one per major theme &#8212; that can flex across dozens of questions.</p><h3>Pattern 7: STAR Imbalance &#8212; Over-investing in Situation and Task</h3><p>STAR fails in practice when candidates over-allocate time to setup. STAR often causes candidates to ramble on the least important part of the answer: the background. The Action and Result sections are where the evidence actually lives. Interviewers lose interest during extended Situation framing and miss the payoff entirely.</p><h3>Pattern 8: No Measurable Results</h3><p>&#8220;The project was successful and everyone was happy&#8221; provides zero evaluative signal. FAANG interviewers are trained to probe for quantifiable impact: &#8220;What was the quantifiable impact? How did this affect the business, customers, or team?&#8221; Even approximate metrics are significantly better than vague qualitative claims. Examples of strong result framing: &#8220;downtime dropped by approximately 80%,&#8221; &#8220;user engagement increased 14%,&#8221; &#8220;we regained 8% market share within the first quarter.&#8221;</p><h3>Pattern 9: Treating Behavioral as Subjective and Not Worth Preparing</h3><p>This is the most destructive myth because it stops candidates from preparing at all. FAANG companies have invested heavily in making behavioral evaluations structured and consistent: training interviewers, using rubrics and running debrief committees. Many candidates spend dozens of hours on LeetCode and zero hours on behavioral stories; this alone makes them statistically more likely to fail.</p><h3>Pattern 10: Ignoring Company-Specific Value Mapping</h3><p>A story that demonstrates Amazon&#8217;s &#8220;Earn Trust&#8221; LP perfectly may not map to Google&#8217;s Googleyness dimension or Meta&#8217;s &#8220;growing continuously&#8221; competency. Generic STAR answers that do not explicitly connect to company values leave the interviewer doing guesswork. Strong candidates research the company&#8217;s specific behavioral framework and map each story to it before the interview.</p><div><hr></div><h2>Why Behavioral Prep Frameworks Succeed: What Interviewers Consistently Reward</h2><h3>Build Versatile Story Fixtures, Not a Question Map</h3><p>Eight to ten carefully selected stories from your career &#8212; covering leadership, conflict, failure, ambiguity, tight deadlines, cross-team work and technical tradeoffs &#8212; can cover approximately 40 behavioral questions. The key is selecting stories that are rich enough to answer multiple question types and adaptable enough to emphasize different dimensions based on what the interviewer is probing.</p><h3>Decode the Rubric Before You Prep</h3><p>Every behavioral question is hunting for specific evidence. Understanding what the interviewer wants changes everything. Effective preparation starts with reading the company&#8217;s public documentation &#8212; Amazon&#8217;s LPs, Netflix&#8217;s Culture Memo, Google&#8217;s re:Work resources on Googleyness &#8212; and then working backwards to identify which stories in your library satisfy each rubric dimension.</p><h3>Quantify Everything</h3><p>Strong STAR answers include measurable outcomes as a default, not as an afterthought. Quantification signals credibility and scope: &#8220;We launched two weeks ahead of schedule, which led to a 14% increase in user engagement and helped us regain 8% market share within the first quarter.&#8221; Even in qualitative stories about conflict or growth, anchoring the impact in business terms (revenue, reliability, team velocity) elevates the answer.</p><h3>Add STAR-L: Make Learning Explicit</h3><p>For failure, growth, and mistake questions, which all major FAANG companies ask, adding an explicit &#8220;Learnings&#8221; layer after the Result is critical. Interviewers are evaluating three things in failure questions: whether you take full responsibility, whether you extract concrete lessons, and whether you built systematic safeguards to prevent recurrence. Candidates who end their story at &#8220;the outcome was X&#8221; leave out the most important evaluative evidence.</p><h3>Practice Out Loud Against Follow-Ups</h3><p>Mock interviews with a peer, a coach, or a recording are the highest-value behavioral prep activity. The goal is not to achieve a perfect rehearsed answer, but to identify where answers break down under pressure: where you over-explain, where results disappear, and where follow-up questions expose thin coverage. Specifically practicing the edge cases &#8212; &#8220;What would you do differently?&#8221; &#8220;Why didn&#8217;t you escalate sooner?&#8221; &#8220;How did you prevent it from happening again?&#8221; &#8212; separates candidates who merely pass from those who give strong hire signals.</p><h3>Calibrate Story Scope to the Target Level</h3><p>Before an interview, map each story to its approximate scope level. If you&#8217;re targeting a senior role, every story should involve multi-person coordination, cross-team stakeholder management or org-level business impact. If you&#8217;re targeting staff or principal, stories should demonstrate org-wide or XFN influence with measurable strategic outcomes and independent scope creation. <strong>Scope calibration is the single most reliable way to avoid being down-leveled.</strong></p><div><hr></div><h2>Universal Cross-FAANG Success Patterns</h2><p>Across all five companies, experienced interviewers consistently reward the following behavioral signals regardless of company-specific rubric:</p><ul><li><p><strong>Influence without authority</strong> &#8212; building consensus through data and shared goals, not hierarchy</p></li><li><p><strong>Disagree and commit</strong> &#8212; respectfully challenging decisions, then committing fully once a direction is set</p></li><li><p><strong>Ownership under ambiguity</strong> &#8212; proactively defining scope and driving progress without being told what to do</p></li><li><p><strong>Quantified business impact</strong> &#8212; connecting engineering actions to revenue, reliability or customer outcomes</p></li><li><p><strong>Postmortem mindset</strong> &#8212; systematic prevention after failure, not just incident recovery</p></li><li><p><strong>Intellectual humility</strong> &#8212; acknowledging limitations, seeking feedback and demonstrating growth from both success and failure</p></li></ul><div><hr></div><h2>Conclusion</h2><p>Behavioral interview prep frameworks succeed when they are used as evidence-gathering tools, helping candidates retrieve and present specific, calibrated proof of past behaviors aligned to a company&#8217;s rubric. They fail when candidates use them as scripts for generic storytelling. The most durable preparation strategy is to build a library of versatile, quantified, level-appropriate stories; decode each company&#8217;s specific evaluation framework; and practice until verbal delivery matches the internal clarity of the story. The behavioral round is not a personality contest. It&#8217;s a structured evidence review, and it rewards candidates who prepare for it with the same rigor they apply to technical rounds.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">The Coding Interview Gym is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[When to Reach for BFS vs DFS in Interviews]]></title><description><![CDATA[Rule of thumb, examples and code]]></description><link>https://paulepps.substack.com/p/when-to-reach-for-bfs-vs-dfs-in-interviews</link><guid isPermaLink="false">https://paulepps.substack.com/p/when-to-reach-for-bfs-vs-dfs-in-interviews</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Wed, 01 Apr 2026 02:00:32 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!K9fH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Use BFS when the problem cares about <em>distance from a source</em> or <em>doing work level&#8209;by&#8209;level</em>; use DFS for almost everything else, especially when the search space is deep or you are building/validating paths, combinations, or structures.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!K9fH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!K9fH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 424w, https://substackcdn.com/image/fetch/$s_!K9fH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 848w, https://substackcdn.com/image/fetch/$s_!K9fH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 1272w, https://substackcdn.com/image/fetch/$s_!K9fH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!K9fH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png" width="791" height="450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:450,&quot;width&quot;:791,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:711834,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/192059917?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!K9fH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 424w, https://substackcdn.com/image/fetch/$s_!K9fH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 848w, https://substackcdn.com/image/fetch/$s_!K9fH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 1272w, https://substackcdn.com/image/fetch/$s_!K9fH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4fd1e018-d66f-40c7-97f8-12e06a6e0bb9_791x450.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Core rule&#8209;of&#8209;thumb</h2><p>A simple mental checklist you can actually run in an interview:</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">The Coding Interview Gym is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><ol><li><p><strong>Default to BFS</strong> from the starting node if the question says things like:</p><ul><li><p>&#8220;shortest path / minimum number of steps / fewest edges&#8221;</p></li><li><p>&#8220;all nodes at distance k / level order / by layer&#8221;</p></li><li><p>&#8220;nearest X / first time you can reach Y&#8221;</p></li></ul></li><li><p><strong>Default to DFS</strong>, usually with recursion/backtracking, if you&#8217;re:</p><ul><li><p>exploring all ways to build something (paths, subsets, permutations)</p></li><li><p>checking if <em>any</em> or <em>all</em> paths satisfy a property</p></li><li><p>traversing trees/graphs without an explicit &#8220;fewest steps&#8221; requirement</p></li></ul></li></ol><p>If you&#8217;re unsure in the moment, start with DFS; it&#8217;s usually less code and maps directly to recursion on trees, graphs, and backtracking problems.</p><h2>Interview&#8209;style examples</h2><h3>When BFS is the right first move</h3><ul><li><p>Shortest path in an unweighted graph</p><ul><li><p>&#8220;You&#8217;re given friendships as an undirected graph, find the minimum number of introductions between A and B.&#8221;</p></li><li><p>BFS from A, stop when you first see B; that level is your answer.</p></li></ul></li><li><p>Minimum steps in a grid / maze</p><ul><li><p>&#8220;Given a 2D grid of 0s and 1s, what is the minimum number of moves from start to finish if you can move up/down/left/right?&#8221;</p></li><li><p>Model each cell as a node and run BFS; each BFS &#8220;layer&#8221; is one extra step.</p></li></ul></li><li><p>Level&#8209;order operations on a tree</p><ul><li><p>&#8220;Return the values of a binary tree level by level.&#8221;</p></li><li><p>&#8220;Right side view&#8221; / &#8220;average per level&#8221; / &#8220;largest value in each row.&#8221;</p></li><li><p>Use BFS with a queue; process one level at a time.</p></li></ul></li><li><p>Multi&#8209;source nearest distance</p><ul><li><p>&#8220;You&#8217;re given all locations of fire stations and all houses; for each house, find distance to nearest station.&#8221;</p></li><li><p>Push all stations into the BFS queue initially and expand outward; the first time you reach a house is its minimum distance.</p></li></ul></li></ul><h3>When DFS is the right first move</h3><ul><li><p>Tree traversals without level requirements</p><ul><li><p>&#8220;Is the tree height&#8209;balanced?&#8221;</p></li><li><p>&#8220;Is there a root&#8209;to&#8209;leaf path that sums to target?&#8221;</p></li><li><p>Recursive DFS (post&#8209;order, pre&#8209;order, in&#8209;order) keeps code compact and natural.</p></li></ul></li><li><p>Backtracking / combinatorial search</p><ul><li><p>&#8220;Generate all subsets / permutations / combinations that satisfy constraint X.&#8221;</p></li><li><p>&#8220;Solve N&#8209;Queens / Sudoku / word search.&#8221;</p></li><li><p>These are DFS by nature: choose, explore deeper, undo (backtrack) and continue.&#8203;</p></li></ul></li><li><p>Region / component exploration</p><ul><li><p>&#8220;Count the number of islands of 1s in a 2D grid.&#8221;</p></li><li><p>&#8220;Find connected components in an undirected graph.&#8221;</p></li><li><p>Pick a starting cell/node and DFS to mark the entire component; repeat.</p></li></ul></li><li><p>Deep search where solution is likely far</p><ul><li><p>If you expect the answer to be buried deep and the branching factor is large, DFS tends to use less memory than BFS because it stores only a path plus a visited set, not whole frontiers.</p></li></ul></li></ul><h2>Concrete snippets you can reuse</h2><h3>BFS for shortest path in a grid (Python)</h3><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;python&quot;,&quot;nodeId&quot;:&quot;37f1f5ac-3579-4bae-8119-04ee5789492b&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-python">from collections import deque

def shortest_path(grid, start, target):
    rows, cols = len(grid), len(grid[0])
    sr, sc = start
    tr, tc = target
    q = deque([(sr, sc, 0)])  # (row, col, distance)
    visited = {(sr, sc)}

    while q:
        r, c, dist = q.popleft()
        if (r, c) == (tr, tc):
            return dist

        for dr, dc in [(1,0), (-1,0), (0,1), (0,-1)]:
            nr, nc = r + dr, c + dc
            if 0 &lt;= nr &lt; rows and 0 &lt;= nc &lt; cols:
                if grid[nr][nc] == 0 and (nr, nc) not in visited:
                    visited.add((nr, nc))
                    q.append((nr, nc, dist + 1))
    return -1  # unreachable
</code></pre></div><p>You can translate this directly to Java, C#, or JavaScript by swapping in a queue implementation and a visited set.</p><h3>DFS for &#8220;is there a root&#8209;to&#8209;leaf path with sum target?&#8221; (Java)</h3><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;java&quot;,&quot;nodeId&quot;:&quot;98219b9f-88da-4c2d-8fcd-2897bea2a559&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-java">class Solution {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root == null) return false;
        return dfs(root, targetSum);
    }

    private boolean dfs(TreeNode node, int remaining) {
        if (node == null) return false;

        remaining -= node.val;
        if (node.left == null &amp;&amp; node.right == null) {
            return remaining == 0;
        }

        return dfs(node.left, remaining) || dfs(node.right, remaining);
    }
}
</code></pre></div><p>This is DFS: follow a path down, carry state (remaining sum), and short&#8209;circuit as soon as you find a valid leaf.</p><h3>DFS flood&#8209;fill in a grid (C#)</h3><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;csharp&quot;,&quot;nodeId&quot;:&quot;530fddc2-6929-4ded-81ab-f9b3f4a57659&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-csharp">int CountIslands(int[][] grid) {
    int rows = grid.Length, cols = grid[0].Length;
    int count = 0;

    void Dfs(int r, int c) {
        if (r &lt; 0 || r &gt;= rows || c &lt; 0 || c &gt;= cols) return;
        if (grid[r][c] == 0) return;
        grid[r][c] = 0; // mark visited
        Dfs(r+1, c); Dfs(r-1, c); Dfs(r, c+1); Dfs(r, c-1);
    }

    for (int r = 0; r &lt; rows; r++) {
        for (int c = 0; c &lt; cols; c++) {
            if (grid[r][c] == 1) {
                count++;
                Dfs(r, c);
            }
        }
    }
    return count;
}
</code></pre></div><p>Any similar &#8220;count regions / flood&#8209;fill&#8221; interview problem has essentially this DFS core.</p><h2>Memory, complexity, and &#8220;feel&#8221; in the room</h2><ul><li><p>Time</p><ul><li><p>Both BFS and DFS are <em>O(V + E)</em> on graphs: you visit each node and edge at most once.</p></li></ul></li><li><p>Space</p><ul><li><p>BFS can blow up if the branching factor is large and the solution is deep; the frontier can hold an entire level.</p></li><li><p>DFS typically stores just one path plus recursion/stack frames; if the tree/graph is very deep, recursion depth can be a concern.</p></li></ul></li></ul><p>In an interview, it often helps to say out loud: &#8220;Because the problem asks for the <em>minimum number of steps</em>, I&#8217;ll start with BFS from the starting node so that the first time I hit the target is guaranteed to be the shortest path.&#8221; or &#8220;We don&#8217;t care about shortest paths; we just need to explore all possibilities and prune bad ones, so DFS with backtracking is a good fit here.&#8221;</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">The Coding Interview Gym is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Binary Tree Patterns You Actually Need in Interviews]]></title><description><![CDATA[DFS/level&#8209;order, recursion vs iteration, common traps]]></description><link>https://paulepps.substack.com/p/binary-tree-patterns-you-actually</link><guid isPermaLink="false">https://paulepps.substack.com/p/binary-tree-patterns-you-actually</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Thu, 12 Mar 2026 03:28:53 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!sYB2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sYB2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sYB2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!sYB2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!sYB2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!sYB2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sYB2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png" width="586" height="390.8008241758242" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:586,&quot;bytes&quot;:2715687,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/190672824?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sYB2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!sYB2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!sYB2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!sYB2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feefcbb93-037d-4076-b852-1683fb63e981_1536x1024.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>You can treat binary tree questions as a handful of reusable <strong>patterns</strong>, not a grab&#8209;bag of one&#8209;off tricks.</p><h2>Big picture: three patterns</h2><p>In most interviews, tree problems resolve into three ideas.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Coding Interview Gym! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><ul><li><p>Depth&#8209;first traversals (in&#8209;order / pre&#8209;order / post&#8209;order) for &#8220;touch every node&#8221; logic, especially on BSTs.</p></li><li><p>Level&#8209;order (BFS) for anything involving &#8220;by level,&#8221; &#8220;shortest path,&#8221; or &#8220;first/last node on a level.&#8221;</p></li><li><p>Path/subtree recursion for questions about &#8220;sum/max/min on some path/subtree&#8221; (e.g., max path sum, diameter, balanced tree).</p></li></ul><p>If you can do these with both recursion and iteration and talk through complexity and edge cases, you&#8217;re better prepared than most candidates.</p><h2>Pattern 1: in&#8209;order and friends</h2><p>For DFS traversals, memorize &#8220;what do I do at each node&#8221; and &#8220;when do I do it.&#8221;</p><ul><li><p>In&#8209;order (left, root, right): default for BST problems (sorted order, kth smallest, validate BST, median).</p></li><li><p>Pre&#8209;order (root, left, right): good for serialization/deserialization and &#8220;copy this tree&#8221; style problems.</p></li><li><p>Post&#8209;order (left, right, root): use when the answer at a node depends on its children (height, diameter, max path sum, distribute coins, delete tree).</p></li></ul><p>Interview&#8209;ready talking points.</p><ul><li><p>Time: visit each node once &#8594; <em>O</em>(<em>n</em>).</p></li><li><p>Space (recursive): call&#8209;stack <em>O</em>(<em>h</em>) where <em>h</em> is height; worst&#8209;case <em>O</em>(<em>n</em>) on skewed trees.</p></li><li><p>Space (iterative): explicit stack also <em>O</em>(<em>h</em>); interviewer mainly cares that you can express either.</p></li></ul><p>Example mental template (in&#8209;order, recursive).</p><ul><li><p>Recurse left.</p></li><li><p>&#8220;Do work&#8221; at current node (add to list, check order, update counter).</p></li><li><p>Recurse right.</p></li></ul><p>You can drop almost any BST question into that template and just change the &#8220;do work&#8221; line.</p><h2>Pattern 2: level&#8209;order (BFS)</h2><p>Level&#8209;order = queue + &#8220;process current level before moving on.&#8221;</p><p>Use it when the prompt mentions:</p><ul><li><p>&#8220;level,&#8221; &#8220;row,&#8221; &#8220;layer,&#8221; &#8220;width,&#8221; &#8220;zigzag,&#8221; &#8220;next pointers,&#8221; &#8220;left/right side view,&#8221; &#8220;shortest path.&#8221;&#8203;</p></li><li><p>Distance in edges (minimum depth, nearest leaf, shortest transformation using a tree as a graph).</p></li></ul><p>Standard queue template.</p><ul><li><p>Push root.</p></li><li><p>While queue not empty, pop nodes of the current level (size = queue length at loop start), process them, and push their children.</p></li></ul><p>Example: left side view.&#8203;</p><ul><li><p>For each level, remember the first node you see (or last, depending on traversal order) and append to result; everything else is boilerplate BFS.&#8203;</p></li></ul><p>Talking points.</p><ul><li><p>Time <em>O</em>(<em>n</em>).</p></li><li><p>Space <em>O</em>(<em>w</em>), where <em>w</em> is max width (up to <em>O</em>(<em>n</em>)); that&#8217;s your answer if asked about worst case.</p></li></ul><h2>Recursion vs iteration in interviews</h2><p>Most interviewers are fine with recursion as long as you can reason clearly about the call stack.</p><p>When recursion is preferred.</p><ul><li><p>Tree problems with simple, top&#8209;down or bottom&#8209;up definitions (height, max path sum, validate BST).</p></li><li><p>When clarity matters more than worst&#8209;case stack depth and the tree isn&#8217;t absurdly deep.</p></li></ul><p>When iteration is worth showing.</p><ul><li><p>The prompt explicitly says &#8220;no recursion&#8221; or &#8220;use iteration/stack/queue.&#8221;&#8203;</p></li><li><p>You&#8217;ve just written a recursive solution; offer a quick &#8220;I can also do this iteratively with an explicit stack if you&#8217;d like,&#8221; especially for in&#8209;order or pre&#8209;order.</p></li><li><p>You want to highlight awareness of stack&#8209;overflow risks or tail&#8209;recursion limitations.</p></li></ul><p>How to articulate the tradeoff.</p><ul><li><p>Recursion: simpler and closer to the math definition, but uses call&#8209;stack space <em>O</em>(<em>h</em>) and can overflow on very deep trees.</p></li><li><p>Iteration: a bit more code, but makes stack/queue usage explicit and sometimes easier to optimize.</p></li></ul><h2>Common traps (and how to avoid them)</h2><p>These are the mistakes that actually cost offers, not off&#8209;by&#8209;one in your for&#8209;loop.</p><ul><li><p>Losing track of null and leaf cases: always handle empty tree, single node, and skewed tree; say this out loud before coding.&#8203;</p></li><li><p>Mutating shared state incorrectly in recursion: be clear what each call returns vs what you track in outer scope (e.g., global max path sum, best answer so far).</p></li><li><p>Forgetting that recursion depth = height: mention stack space explicitly in your complexity analysis; interviewers listen for it.</p></li><li><p>Mixing up traversal orders: write a tiny example tree and trace your algorithm for in&#8209;order/pre&#8209;order/post&#8209;order; don&#8217;t rely on memory under pressure.</p></li><li><p>Ignoring BST properties: for any BST question, ask yourself &#8220;can I do better than <em>O</em>(<em>n</em>) by using ordering?&#8221; before you brute&#8209;force.</p></li><li><p>Over&#8209;engineering: if the problem is &#8220;print nodes level by level,&#8221; you do not need fancy data structures; a queue is enough.</p></li></ul><p>An easy practice loop is: pick a LeetCode/Tech Interview Handbook tree problem, solve it once with recursion, once with iteration (if reasonable), and then explain to an imaginary junior what your traversal order is doing at each node.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Coding Interview Gym! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Why experienced devs crash in coding interviews (and how to fix it)]]></title><description><![CDATA[Patterns, simplicity, communication]]></description><link>https://paulepps.substack.com/p/why-experienced-devs-crash-in-coding</link><guid isPermaLink="false">https://paulepps.substack.com/p/why-experienced-devs-crash-in-coding</guid><dc:creator><![CDATA[Paul Epps]]></dc:creator><pubDate>Wed, 11 Mar 2026 04:24:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ZHRl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZHRl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZHRl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ZHRl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ZHRl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ZHRl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZHRl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg" width="580" height="437.1014492753623" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1104,&quot;resizeWidth&quot;:580,&quot;bytes&quot;:304995,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/190582171?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZHRl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ZHRl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ZHRl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ZHRl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F449d1bcc-f35e-49a8-a940-9533fa40855d_1104x832.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Developers often crash in coding interviews because the interview environment rewards a specific skill set: fast pattern recall, rigorous simplicity, and explicit narration of your thinking. The good news is that each of these is learnable with deliberate practice.</p><div><hr></div><h2>The senior&#8211;interview paradox</h2><p>On the job, senior engineers are rewarded for things like long&#8209;term architecture, risk reduction, and mentoring, none of which look anything like solving graph problems on a whiteboard. Coding interviews, especially at big tech and high&#8209;growth companies, are optimized for something narrower:</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Coding Interview Gym! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><ul><li><p>Can you recognize a common algorithmic or design pattern quickly?</p></li><li><p>Can you implement a clean solution in 30&#8211;45 minutes?</p></li><li><p>Can you communicate clearly under mild pressure so a stranger can follow your reasoning?</p></li></ul><p>That mismatch is why experienced engineers walk out of interviews thinking, &#8220;I&#8217;d never do that in real life,&#8221; while interviewers quietly down&#8209;level or reject them.</p><div><hr></div><h2>Rusty pattern recall: you <em>know</em> this, but not fast enough</h2><p>Common issues:</p><ul><li><p>Re&#8209;deriving basics instead of recognizing them (e.g., discovering binary search from scratch instead of naming and applying it).</p></li><li><p>Half&#8209;remembered implementations that lead to off&#8209;by&#8209;ones or missed edge cases.</p></li><li><p>Spending 25 minutes exploring the wrong idea because you didn&#8217;t map the problem to a known pattern early.</p></li></ul><p><strong>How to fix the recall gap</strong></p><p>You do not need to become a grind&#8209;every&#8209;day LeetCoder, but you <em>do</em> need a refreshed mental index:</p><ul><li><p>Curate a small pattern pack: arrays/strings, hash maps/sets, two&#8209;pointers, binary search, heaps, DFS/BFS, backtracking, common tree and graph traversals, basic DP, and a few classic greedy patterns.</p></li><li><p>For each pattern, pick 2&#8211;3 representative problems and solve them end&#8209;to&#8209;end with time pressure. When you finish, explicitly label the pattern out loud: &#8220;This was multi&#8209;source BFS on a grid with a queue.&#8221;</p></li><li><p>Build a &#8220;pattern checklist&#8221; you silently run at the start of each question: &#8220;Is this sorted? Can I sort it? Graph? Tree? Sliding window? Interval scheduling?&#8221;</p></li></ul><p>This turns interview questions from puzzles into &#8220;find&#8209;the&#8209;right&#8209;template and tailor it&#8221; exercises.</p><div><hr></div><h2>Over&#8209;engineering: when &#8220;staff energy&#8221; looks junior</h2><p>In real systems, thinking ahead and exploring alternatives is a mark of seniority. In a 45&#8209;minute interview, trying to anticipate future requirements often reads as &#8220;doesn&#8217;t understand scope&#8221; or &#8220;loves shiny tech.&#8221;</p><p>Typical over&#8209;engineering moves:</p><ul><li><p>Introducing frameworks, complex data structures, or distributed components for a toy problem (&#8220;let&#8217;s put a message queue and a search cluster in front of this CRUD API&#8221;).</p></li><li><p>Premature optimization: worrying about sharding, caching layers, or lock&#8209;free structures when the interviewer only wants a correct single&#8209;node solution.</p></li><li><p>Trying to design a generic library when the prompt is asking for a concrete function.</p></li></ul><p>From the interviewer&#8217;s chair, this creates three problems:</p><ul><li><p>You run out of time on the basics.</p></li><li><p>You can&#8217;t go deep on any one component because you&#8217;ve scattered your attention.</p></li><li><p>It suggests you may be expensive to manage in a codebase that values simplicity.</p></li></ul><p><strong>How to show senior judgment instead</strong></p><p>You still want to show you think beyond the toy version, but in layers:</p><ol><li><p>Start with the simplest design that clearly meets the stated requirements, even if it wouldn&#8217;t scale in production.</p></li><li><p>Get agreement: &#8220;I&#8217;ll start with a straightforward in&#8209;memory solution, then we can talk about how to scale or harden it if time allows.&#8221;</p></li><li><p>Implement that simple version cleanly.</p></li><li><p>Only <em>after</em> it works, mention one or two realistic evolutions: &#8220;If this needed to serve millions of users, I&#8217;d first add caching here, then consider sharding by user ID; we can dig into either if that&#8217;s interesting.&#8221;</p></li></ol><p>This sequence shows that you can triage complexity rather than default to it.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!h1L6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!h1L6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 424w, https://substackcdn.com/image/fetch/$s_!h1L6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 848w, https://substackcdn.com/image/fetch/$s_!h1L6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!h1L6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!h1L6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg" width="601" height="251.13832853025937" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:145,&quot;width&quot;:347,&quot;resizeWidth&quot;:601,&quot;bytes&quot;:11706,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://paulepps.substack.com/i/190582171?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!h1L6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 424w, https://substackcdn.com/image/fetch/$s_!h1L6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 848w, https://substackcdn.com/image/fetch/$s_!h1L6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!h1L6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F560cf404-5c07-4598-a65d-5c40aa007e38_347x145.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><h2>Communication gaps: invisible failure modes</h2><p>In modern interview loops, your communication is as heavily weighted as your correctness.</p><p>Common communication pitfalls:</p><ul><li><p>Diving straight into coding without restating the problem or clarifying constraints.</p></li><li><p>Long silent stretches while you&#8217;re thinking, which makes it impossible for the interviewer to help you course&#8209;correct.</p></li><li><p>Non&#8209;structured rambles about tradeoffs that don&#8217;t land on a clear recommendation.</p></li></ul><p>Interviewers, especially for senior roles, want to see you as a partner they could comfortably pair&#8209;program or design with. When they can&#8217;t follow you, they assume working with you will feel similar.</p><p><strong>How to communicate in the room</strong></p><p>Treat the interviewer like a temporary teammate, not a judge:</p><ul><li><p>Start with a crisp restatement: &#8220;Let me confirm: given X and Y constraints, we want Z output in O(&#8230;) if possible, right?&#8221;</p></li><li><p>Outline before implementation: &#8220;High&#8209;level plan: I&#8217;ll parse the input, use a hash map to count, then scan once to find the minimum index of a valid candidate.&#8221;</p></li><li><p>Think out loud about tradeoffs: &#8220;We could sort for O(n log n) or use extra memory for O(n); I&#8217;d pick the second since space is cheap here.&#8221;</p></li><li><p>Check in periodically: &#8220;Does that approach align with what you had in mind, or did you want me to explore a different direction?&#8221;</p></li><li><p>After coding, narrate testing: walk through normal and edge cases and call out time and space complexity explicitly.</p></li></ul><p>You&#8217;re signaling not just that you can solve problems, but that you can lead <strong>clear</strong> technical conversations.</p><div><hr></div><h2>A practical tune&#8209;up plan</h2><ol><li><p><strong>Week 1&#8211;2: refresh your toolbox</strong></p><ul><li><p>Revisit core patterns and algorithms with a concise guide or curated set of problems.</p></li><li><p>Implement each from scratch in your primary interview language until it feels automatic.</p></li></ul></li><li><p><strong>Week 3: enforce simplicity drills</strong></p><ul><li><p>For each practice problem or system design prompt, force yourself to propose the dumbest thing that works first.</p></li><li><p>Only after it&#8217;s working are you allowed to mention optimizations or additional components.</p></li></ul></li><li><p><strong>Week 4: communication bootcamp</strong></p><ul><li><p>Do 4&#8211;6 mock interviews with peers or a coaching platform, focusing purely on narration, structure, and pacing.</p></li><li><p>Record a couple of sessions, listen back, and write a short script for your openings (&#8220;restatement + constraints + plan&#8221;) and closings (&#8220;complexity + next improvements&#8221;).</p></li></ul></li><li><p><strong>Ongoing: interview&#8209;specific reps, not lifetime habits</strong></p><ul><li><p>Treat this like training for a race: deliberate, time&#8209;boxed, and with a taper.</p></li><li><p>Once your &#8220;interview muscles&#8221; are warm, maintenance practice once a week is usually enough.</p></li></ul></li></ol><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://paulepps.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Coding Interview Gym! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>