<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Path: Algorithms on Tech Interview Prep</title>
    <link>https://pankajpipada.com/tech-interview-prep/algorithms/</link>
    <description>Recent content in Path: Algorithms on Tech Interview Prep</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>Copyright © 2016-Present Pankaj Pipada. All Rights Reserved.</copyright>
    <atom:link href="https://pankajpipada.com/tech-interview-prep/algorithms/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Quick Notes</title>
      <link>https://pankajpipada.com/tech-interview-prep/algorithms/quick-notes/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://pankajpipada.com/tech-interview-prep/algorithms/quick-notes/</guid>
      <description>&lt;h1 id=&#34;algorithms-quick-notes&#34;&gt;Algorithms: Quick Notes&lt;a class=&#34;anchor&#34; href=&#34;#algorithms-quick-notes&#34;&gt;#&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;h2 id=&#34;bitmasks&#34;&gt;Bitmasks&lt;a class=&#34;anchor&#34; href=&#34;#bitmasks&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Bitmasking performs operations at the bit level (often faster and memory-efficient).&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Commonly used for:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;subset representation (set of small integers),&lt;/li&gt;&#xA;&lt;li&gt;DP over subsets,&lt;/li&gt;&#xA;&lt;li&gt;toggling flags,&lt;/li&gt;&#xA;&lt;li&gt;fast membership checks.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Quick patterns&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Iterate set bits: &lt;code&gt;while s: lsb = s &amp;amp; -s; ...; s -= lsb&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Count bits: Python: &lt;code&gt;s.bit_count()&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enumerate all subsets of a mask: &lt;code&gt;sub = mask; while sub: ...; sub = (sub - 1) &amp;amp; mask&lt;/code&gt; (also include &lt;code&gt;0&lt;/code&gt; separately)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote class=&#39;book-hint &#39;&gt;&#xA;&lt;p&gt;Convention: &lt;code&gt;k&lt;/code&gt; is 0-indexed from LSB (least-significant bit).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Problems</title>
      <link>https://pankajpipada.com/tech-interview-prep/algorithms/problems/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://pankajpipada.com/tech-interview-prep/algorithms/problems/</guid>
      <description>&lt;h1 id=&#34;algorithms-problems&#34;&gt;Algorithms: Problems&lt;a class=&#34;anchor&#34; href=&#34;#algorithms-problems&#34;&gt;#&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;p&gt;Approach problems by core Algorithms / techniques (DP/DFS/BFS/etc.).&lt;/p&gt;&#xA;&#xA;  &lt;ul&gt;&lt;li&gt;&#xA;        &lt;a href=&#34;#bfs&#34;&gt;Bfs&lt;/a&gt;&#xA;        (5)&#xA;      &lt;/li&gt;&lt;li&gt;&#xA;        &lt;a href=&#34;#binary-search&#34;&gt;Binary Search&lt;/a&gt;&#xA;        (4)&#xA;      &lt;/li&gt;&lt;li&gt;&#xA;        &lt;a href=&#34;#dfs&#34;&gt;Dfs&lt;/a&gt;&#xA;        (9)&#xA;      &lt;/li&gt;&lt;li&gt;&#xA;        &lt;a href=&#34;#divide-and-conquer&#34;&gt;Divide and Conquer&lt;/a&gt;&#xA;        (2)&#xA;      &lt;/li&gt;&lt;li&gt;&#xA;        &lt;a href=&#34;#dynamic-programming&#34;&gt;Dynamic Programming&lt;/a&gt;&#xA;        (14)&#xA;      &lt;/li&gt;&lt;li&gt;&#xA;        &lt;a href=&#34;#greedy&#34;&gt;Greedy&lt;/a&gt;&#xA;        (1)&#xA;      &lt;/li&gt;&lt;/ul&gt;&#xA;&#xA;  &lt;h2 id=&#34;bfs&#34;&gt;Bfs&lt;/h2&gt;&#xA;&#xA;    &lt;ul&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/binary-tree-level-order-traversal/&#34;&gt;Binary tree level order traversal&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/clone-graph/&#34;&gt;Clone graph&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/course-schedule/&#34;&gt;Course schedule&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/number-of-islands/&#34;&gt;Number of islands&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/pacific-atlantic-water-flow/&#34;&gt;Pacific-Atlantic water flow&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&#34;binary-search&#34;&gt;Binary Search&lt;/h2&gt;&#xA;&#xA;    &lt;ul&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/find-minimum-in-rotated-sorted-array/&#34;&gt;Find minimum in rotated sorted array&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/kth-smallest-element-in-a-bst/&#34;&gt;Kth smallest element in a BST&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/longest-increasing-subsequence/&#34;&gt;Longest increasing subsequence&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/search-in-rotated-sorted-array/&#34;&gt;Search in rotated sorted array&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&#34;dfs&#34;&gt;Dfs&lt;/h2&gt;&#xA;&#xA;    &lt;ul&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/binary-tree-maximum-path-sum/&#34;&gt;Binary tree maximum path sum&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/clone-graph/&#34;&gt;Clone graph&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/construct-binary-tree-from-preorder-and-inorder-traversal/&#34;&gt;Construct binary tree from preorder and inorder traversal&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/course-schedule/&#34;&gt;Course schedule&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/maximum-depth-of-binary-tree/&#34;&gt;Maximum depth of binary tree&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/number-of-islands/&#34;&gt;Number of islands&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/pacific-atlantic-water-flow/&#34;&gt;Pacific-Atlantic water flow&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/same-tree/&#34;&gt;Same tree&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/validate-binary-search-tree/&#34;&gt;Validate a binary search tree&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&#34;divide-and-conquer&#34;&gt;Divide and Conquer&lt;/h2&gt;&#xA;&#xA;    &lt;ul&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/maximum-subarray/&#34;&gt;Maximum subarray&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/merge-k-sorted-lists/&#34;&gt;Merge k sorted lists&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&#34;dynamic-programming&#34;&gt;Dynamic Programming&lt;/h2&gt;&#xA;&#xA;    &lt;ul&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/climbing-stairs/&#34;&gt;Climbing stairs&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/coin-change/&#34;&gt;Coin change&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/combination-sum-iv/&#34;&gt;Combination sum IV&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/counting-bits/&#34;&gt;Counting bits&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/decode-ways/&#34;&gt;Decode ways&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/house-robber/&#34;&gt;House robber&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/house-robber-ii/&#34;&gt;House robber II&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/jump-game/&#34;&gt;Jump game&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/longest-increasing-subsequence/&#34;&gt;Longest increasing subsequence&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/longest-palindromic-substring/&#34;&gt;Longest palindromic substring&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/maximum-subarray/&#34;&gt;Maximum subarray&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/palindromic-substrings/&#34;&gt;Palindromic substrings&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/unique-paths/&#34;&gt;Unique paths&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/word-break/&#34;&gt;Word break&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&#34;greedy&#34;&gt;Greedy&lt;/h2&gt;&#xA;&#xA;    &lt;ul&gt;&lt;li&gt;&lt;a href=&#34;https://pankajpipada.com/tech-interview-prep/problems/non-overlapping-intervals/&#34;&gt;Non overlapping intervals&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</description>
    </item>
  </channel>
</rss>
