<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <updated>2026-09-26T21:22:51Z</updated>
  <generator>https://yabu.me</generator>

  <title>Nostr notes by codementor</title>
  <author>
    <name>codementor</name>
  </author>
  <link rel="self" type="application/atom+xml" href="https://yabu.me/npub1u69qs4hfpkve0v0hy85s2fycjeqjm4ts8xdfs7ew3l270l87yfuspv0yg2.rss" />
  <link href="https://yabu.me/npub1u69qs4hfpkve0v0hy85s2fycjeqjm4ts8xdfs7ew3l270l87yfuspv0yg2" />
  <id>https://yabu.me/npub1u69qs4hfpkve0v0hy85s2fycjeqjm4ts8xdfs7ew3l270l87yfuspv0yg2</id>
  <icon>https://blossom.primal.net/d87ea72911153368b450df15f0a7cf2040490ec1fd9b9c436c967316690dfcaf.jpg</icon>
  <logo>https://blossom.primal.net/d87ea72911153368b450df15f0a7cf2040490ec1fd9b9c436c967316690dfcaf.jpg</logo>




  <entry>
    <id>https://yabu.me/nevent1qqst3az0nda5sjjs8ef06926jpv2r26fsk0upmkeg7ntda229n5y6nszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jhjmgyx</id>
    
      <title type="html">Learn: The Lock type (.NET 9&#43;) .NET 9 added ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqst3az0nda5sjjs8ef06926jpv2r26fsk0upmkeg7ntda229n5y6nszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jhjmgyx" />
    <content type="html">
      Learn: The Lock type (.NET 9&#43;)&lt;br/&gt;&lt;br/&gt;.NET 9 added System.Threading.Lock, a type made only for locking, and lighter than locking on a plain object.&lt;br/&gt;With the .NET 10 SDK it works in async methods too (older compilers may reject this), as long as there is no await inside the lock block:&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var gate = new Lock();&lt;br/&gt;await Task.Yield();&lt;br/&gt;lock (gate) { Console.WriteLine(&amp;#34;inside&amp;#34;); }&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints inside. An await inside the block is error CS1996, just like with any lock:&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var gate = new Lock();&lt;br/&gt;lock (gate) { await Task.Delay(1); }&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;Need to await while holding a lock? Use SemaphoreSlim.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/api/system.threading.lock&#34;&gt;https://learn.microsoft.com/en-us/dotnet/api/system.threading.lock&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-075
    </content>
    <updated>2026-12-01T17:08:18Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsxtt65mhppygw3rfqj7zjr643a9mxmcml06y94hwcz4up7cxw95vgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jykd2hr</id>
    
      <title type="html">Learn: Thread-safe collections List&amp;lt;T&amp;gt; and Dictionary&amp;lt;K, ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsxtt65mhppygw3rfqj7zjr643a9mxmcml06y94hwcz4up7cxw95vgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jykd2hr" />
    <content type="html">
      Learn: Thread-safe collections&lt;br/&gt;&lt;br/&gt;List&amp;lt;T&amp;gt; and Dictionary&amp;lt;K, V&amp;gt; are not safe to change from several threads at once. For shared data use System.Collections.Concurrent: ConcurrentDictionary and ConcurrentQueue.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var hits = new ConcurrentDictionary&amp;lt;string, int&amp;gt;();&lt;br/&gt;Parallel.For(0, 1000, _ =&amp;gt; hits.AddOrUpdate(&amp;#34;home&amp;#34;, 1, (_, n) =&amp;gt; n &#43; 1));&lt;br/&gt;Console.WriteLine(hits[&amp;#34;home&amp;#34;]);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 1000: no update is lost. But your update function may run more than once, so keep it free of side effects. And hits[&amp;#34;home&amp;#34;]&#43;&#43; is NOT safe: it is a read and a write.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2&#34;&gt;https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-081
    </content>
    <updated>2026-11-30T08:07:48Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsf85uxl997wdf48kx3z35zmtkq8f3lj586d08rmwekq6363sd4vuqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jn9slwa</id>
    
      <title type="html">Learn: SemaphoreSlim, the async-friendly lock A semaphore lets up ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsf85uxl997wdf48kx3z35zmtkq8f3lj586d08rmwekq6363sd4vuqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jn9slwa" />
    <content type="html">
      Learn: SemaphoreSlim, the async-friendly lock&lt;br/&gt;&lt;br/&gt;A semaphore lets up to N callers in at a time. With N = 1 it is a lock that works with await.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var gate = new SemaphoreSlim(1, 1); // one caller at a time, and it works with await&lt;br/&gt;await gate.WaitAsync();&lt;br/&gt;try { await Task.Delay(10); Console.WriteLine(&amp;#34;saved&amp;#34;); }&lt;br/&gt;finally { gate.Release(); }&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints saved. Always release in finally.&lt;br/&gt;Use it to protect code that awaits, or to limit concurrency: new SemaphoreSlim(5, 5) for &amp;#34;at most 5 downloads&amp;#34; (give both numbers, or an extra Release raises the limit). It is not reentrant: if the same caller calls WaitAsync again before Release, it waits forever. WaitAsync can also take a CancellationToken.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/standard/threading/overview-of-synchronization-primitives&#34;&gt;https://learn.microsoft.com/en-us/dotnet/standard/threading/overview-of-synchronization-primitives&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-077
    </content>
    <updated>2026-11-29T18:07:49Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsq3rcnhh6mxkzgtxt42syx9755eqy9h0c68lwwxdx5njetd0777fszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jegrz90</id>
    
      <title type="html">Learn: Two pointers Two indexes walk the data instead of nested ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsq3rcnhh6mxkzgtxt42syx9755eqy9h0c68lwwxdx5njetd0777fszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jegrz90" />
    <content type="html">
      Learn: Two pointers&lt;br/&gt;&lt;br/&gt;Two indexes walk the data instead of nested loops. Two common shapes:&lt;br/&gt;From both ends of a sorted array, to find a pair with a given sum (here 11):&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;int[] a = { 1, 3, 4, 7, 9 };&lt;br/&gt;int left = 0, right = a.Length - 1, target = 11;&lt;br/&gt;while (left &amp;lt; right &amp;amp;&amp;amp; a[left] &#43; a[right] != target)&lt;br/&gt;    if (a[left] &#43; a[right] &amp;lt; target) left&#43;&#43;; else right--;&lt;br/&gt;Console.WriteLine(left &amp;lt; right ? $&amp;#34;{a[left]} &#43; {a[right]}&amp;#34; : &amp;#34;no pair&amp;#34;);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 4 &#43; 7 (or &amp;#34;no pair&amp;#34;). Too small: move left; too big: move right.&lt;br/&gt;Same direction, to remove duplicates from a sorted array in place:&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;int[] a = { 1, 1, 2, 3, 3 };&lt;br/&gt;int w = Math.Min(1, a.Length); // 0 for an empty array&lt;br/&gt;for (int r = 1; r &amp;lt; a.Length; r&#43;&#43;)&lt;br/&gt;    if (a[r] != a[w - 1]) a[w&#43;&#43;] = a[r];&lt;br/&gt;Console.WriteLine(string.Join(&amp;#34; &amp;#34;, a[..w]));&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 1 2 3. Both are O(n) time, O(1) memory.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://www.geeksforgeeks.org/dsa/two-pointers-technique/&#34;&gt;https://www.geeksforgeeks.org/dsa/two-pointers-technique/&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-038
    </content>
    <updated>2026-11-28T07:37:47Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsfz86y2ze22nv5fcfq2kgmnpun6s97mqrvvrsc3wy2un5slldjllgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jg0mh9u</id>
    
      <title type="html">Learn: Divide and conquer The pattern: split the problem into ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsfz86y2ze22nv5fcfq2kgmnpun6s97mqrvvrsc3wy2un5slldjllgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jg0mh9u" />
    <content type="html">
      Learn: Divide and conquer&lt;br/&gt;&lt;br/&gt;The pattern: split the problem into smaller parts of the same kind, solve each part (usually with recursion), then combine the answers.&lt;br/&gt;&lt;br/&gt;Examples: merge sort (split, sort halves, merge), quick sort, binary search (keep only one half).&lt;br/&gt;&lt;br/&gt;Why it helps: splitting in half again and again gives about log n levels, which is where the &amp;#34;log n&amp;#34; in O(n log n) comes from.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://www.geeksforgeeks.org/dsa/divide-and-conquer/&#34;&gt;https://www.geeksforgeeks.org/dsa/divide-and-conquer/&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-036
    </content>
    <updated>2026-11-26T17:38:01Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsv9qf8u7daelnj7k0zml3ws32ngqy4ah5s2t4mxn6phth0l0stdeczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j8vhttp</id>
    
      <title type="html">Learn: Matrix What: a grid of rows and columns; m[row, col] reads ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsv9qf8u7daelnj7k0zml3ws32ngqy4ah5s2t4mxn6phth0l0stdeczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j8vhttp" />
    <content type="html">
      Learn: Matrix&lt;br/&gt;&lt;br/&gt;What: a grid of rows and columns; m[row, col] reads one cell.&lt;br/&gt;Cost: visiting every cell is O(rows × cols).&lt;br/&gt;Use it when: data is naturally a grid: images, game boards, maps, seating plans, or a table of results in dynamic programming.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;int[,] grid = { { 1, 2 }, { 3, 4 } };&lt;br/&gt;int sum = 0;&lt;br/&gt;foreach (int x in grid) sum &#43;= x;&lt;br/&gt;Console.WriteLine($&amp;#34;{grid.GetLength(0)}x{grid.GetLength(1)}, sum {sum}&amp;#34;);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 2x2, sum 10. Common interview moves: walk row by row, walk the diagonal, rotate, or spiral.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://www.geeksforgeeks.org/dsa/matrix/&#34;&gt;https://www.geeksforgeeks.org/dsa/matrix/&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-025
    </content>
    <updated>2026-11-26T09:37:50Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsgf3puz8d4ce992ft0aakmpmztwjg4kzhws4nnq24klleuj25vfzszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jmuwvrt</id>
    
      <title type="html">Learn: Strategy Put each version of an algorithm behind the same ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsgf3puz8d4ce992ft0aakmpmztwjg4kzhws4nnq24klleuj25vfzszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jmuwvrt" />
    <content type="html">
      Learn: Strategy&lt;br/&gt;&lt;br/&gt;Put each version of an algorithm behind the same shape, and choose one at run time. No growing if/else chain.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;Func&amp;lt;decimal, decimal&amp;gt; blackFriday = p =&amp;gt; p * 0.7m;&lt;br/&gt;Console.WriteLine(Checkout(100m, blackFriday));&lt;br/&gt;&lt;br/&gt;static decimal Checkout(decimal price, Func&amp;lt;decimal, decimal&amp;gt; discount) =&amp;gt; discount(price);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 70.0 (decimal keeps one decimal place from 0.7).&lt;br/&gt;In C#, a strategy can be an interface or just a Func. Use it for pricing rules, sorting orders, payment methods.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://www.geeksforgeeks.org/system-design/strategy-pattern-set-1/&#34;&gt;https://www.geeksforgeeks.org/system-design/strategy-pattern-set-1/&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-053
    </content>
    <updated>2026-11-23T09:07:38Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsv69xuzx0a8y3rvpz3dal775kafknywdfd8x8cy4tmplgj0hye47qzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j9qxsad</id>
    
      <title type="html">Learn: Thread-safe collections List&amp;lt;T&amp;gt; and Dictionary&amp;lt;K, ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsv69xuzx0a8y3rvpz3dal775kafknywdfd8x8cy4tmplgj0hye47qzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j9qxsad" />
    <content type="html">
      Learn: Thread-safe collections&lt;br/&gt;&lt;br/&gt;List&amp;lt;T&amp;gt; and Dictionary&amp;lt;K, V&amp;gt; are not safe to change from several threads at once. For shared data use System.Collections.Concurrent: ConcurrentDictionary and ConcurrentQueue.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var hits = new ConcurrentDictionary&amp;lt;string, int&amp;gt;();&lt;br/&gt;Parallel.For(0, 1000, _ =&amp;gt; hits.AddOrUpdate(&amp;#34;home&amp;#34;, 1, (_, n) =&amp;gt; n &#43; 1));&lt;br/&gt;Console.WriteLine(hits[&amp;#34;home&amp;#34;]);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 1000: no update is lost. But your update function may run more than once, so keep it free of side effects. And hits[&amp;#34;home&amp;#34;]&#43;&#43; is NOT safe: it is a read and a write.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2&#34;&gt;https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-081
    </content>
    <updated>2026-11-22T07:07:38Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsz50kr2v9t3y5qr7ukpgq5wnpsg9yxl2q2ydgp8g0pyyrmdx6wcpczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j3gy7zw</id>
    
      <title type="html">Learn: The lock statement lock lets only one thread at a time run ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsz50kr2v9t3y5qr7ukpgq5wnpsg9yxl2q2ydgp8g0pyyrmdx6wcpczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j3gy7zw" />
    <content type="html">
      Learn: The lock statement&lt;br/&gt;&lt;br/&gt;lock lets only one thread at a time run a block of code; the others wait.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var sync = new object();&lt;br/&gt;int total = 0;&lt;br/&gt;Parallel.For(0, 1000, i =&amp;gt; { lock (sync) total &#43;= i; });&lt;br/&gt;Console.WriteLine(total);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 499500 (0 &#43; 1 &#43; ... &#43; 999) every time. On a plain object, lock is Monitor.Enter/Exit in a try/finally, so it is released even when an exception is thrown, and the same thread may enter it again (it is reentrant).&lt;br/&gt;Rules: lock on a private object, never on this, a string or a type. Keep the block short. You can&amp;#39;t await inside a lock.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock&#34;&gt;https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/lock&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-074
    </content>
    <updated>2026-11-21T19:07:41Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqs8k5kp0yeceza3wm8an75q5yls96e3l9esgp0nne525cw4nwjdxxczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j6wu72t</id>
    
      <title type="html">Learn: Never change a key while it is in a HashSet A HashSet or ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqs8k5kp0yeceza3wm8an75q5yls96e3l9esgp0nne525cw4nwjdxxczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j6wu72t" />
    <content type="html">
      Learn: Never change a key while it is in a HashSet&lt;br/&gt;&lt;br/&gt;A HashSet or Dictionary files each key by its hash code. If the key changes, its hash code changes, and the set looks in the wrong place.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var p = new Point { X = 1 };&lt;br/&gt;var set = new HashSet&amp;lt;Point&amp;gt; { p };&lt;br/&gt;p.X = 2; // changes p&amp;#39;s hash code&lt;br/&gt;Console.WriteLine(set.Contains(p));&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints False, even though p is in the set. Use keys that can&amp;#39;t change, like strings, numbers or records without setters.&lt;br/&gt;&lt;br/&gt;#tip · TIP-012
    </content>
    <updated>2026-11-21T13:37:42Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsq5tf4nryru73xjj4dxwvzm8xmkx56hgpf3uetq9npyy8uy883rxgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j30fczv</id>
    
      <title type="html">Learn: Repository and Unit of Work Repository: hides data access ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsq5tf4nryru73xjj4dxwvzm8xmkx56hgpf3uetq9npyy8uy883rxgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j30fczv" />
    <content type="html">
      Learn: Repository and Unit of Work&lt;br/&gt;&lt;br/&gt;Repository: hides data access behind an interface like IOrderRepository with GetById and Add, so the rest of the code doesn&amp;#39;t know about SQL.&lt;br/&gt;Unit of Work: collects changes and saves them together in one transaction.&lt;br/&gt;&lt;br/&gt;Interview point: in EF Core, a DbSet already acts like a repository and the DbContext like a unit of work (SaveChanges). Add your own repository when you want to hide EF Core or make testing easier, not by habit.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://www.geeksforgeeks.org/system-design/software-design-patterns/&#34;&gt;https://www.geeksforgeeks.org/system-design/software-design-patterns/&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-070
    </content>
    <updated>2026-11-18T14:07:44Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqs97a2qjsunt7kml99chcdljvuhluy58uej63w42dm329fnjndygcgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jt0s8fm</id>
    
      <title type="html">Question: Everyone has about 100 friends, and the two people are ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqs97a2qjsunt7kml99chcdljvuhluy58uej63w42dm329fnjndygcgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jt0s8fm" />
    <content type="html">
      Question: Everyone has about 100 friends, and the two people are 4 steps apart.&lt;br/&gt;&lt;br/&gt;Roughly how many people does a BFS from one side look at? What if you search from both people at once until the searches meet?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#sd002 · SD-002-Q2
    </content>
    <updated>2026-11-02T11:07:58Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqstazj6xy9qw23zmpc59alezntz5ax6sutkldxm0mjhsh0jw0h50rczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38ja3jxr4</id>
    
      <title type="html">Question: A simpler version: at each node, call a separate ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqstazj6xy9qw23zmpc59alezntz5ax6sutkldxm0mjhsh0jw0h50rczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38ja3jxr4" />
    <content type="html">
      Question: A simpler version: at each node, call a separate Height(left) and Height(right), compare them, then check both children the same way.&lt;br/&gt;&lt;br/&gt;It is correct. What does it cost?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#tg004 · TG-004-Q2
    </content>
    <updated>2026-10-27T11:07:58Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsyqfzh0cuqfxj3yw0w5tyrzvgxukty9tlc22unswjkfnw8yz5yd9szyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jglz7a3</id>
    
      <title type="html">Learn: Containers A container packs an app with the runtime and ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsyqfzh0cuqfxj3yw0w5tyrzvgxukty9tlc22unswjkfnw8yz5yd9szyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jglz7a3" />
    <content type="html">
      Learn: Containers&lt;br/&gt;&lt;br/&gt;A container packs an app with the runtime and libraries it needs into one image. Settings come from outside (environment variables, a Kubernetes ConfigMap), so the same image runs on a laptop, a test server and production.&lt;br/&gt;Docker builds and runs containers from a Dockerfile.&lt;br/&gt;Why it matters: no more &amp;#34;works on my machine&amp;#34;, fast start-up, and it is the unit Kubernetes runs.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://roadmap.sh/devops&#34;&gt;https://roadmap.sh/devops&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-059
    </content>
    <updated>2026-10-10T13:38:00Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqswn4pdvm3pt4waxgnpp78y2l05ls8f5atfq0wfrkxft7ylq4tjf8czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38ju0l4wp</id>
    
      <title type="html">Question: A linked list may have a loop. Return the node where ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqswn4pdvm3pt4waxgnpp78y2l05ls8f5atfq0wfrkxft7ylq4tjf8czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38ju0l4wp" />
    <content type="html">
      Question: A linked list may have a loop. Return the node where the loop starts (or report that there is none), using O(1) extra memory.&lt;br/&gt;&lt;br/&gt;(CtCI 2.8)&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#ll012 · LL-012-Q1
    </content>
    <updated>2026-10-10T13:08:05Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsptdmahdwrfg4gkd3l7jx64v8jrpnfnet26z7r3t7m3k73k67c93qzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jmlqf7f</id>
    
      <title type="html">Learn: Merge sort, step by step How merge sort splits, sorts and ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsptdmahdwrfg4gkd3l7jx64v8jrpnfnet26z7r3t7m3k73k67c93qzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jmlqf7f" />
    <content type="html">
      In reply to &lt;a href=&#39;/naddr1qqt4gj2s95crxd6qxgcryd3dxycz6vfs2scn2vesqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsyg8x3gy9d6gdnxtmraepayzjfxykgyka2upen2v8kt506hnlel3z0ypsgqqqw4rstarmas&#39;&gt;naddr1qq…rmas&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;Learn: Merge sort, step by step&lt;br/&gt;&lt;br/&gt;How merge sort splits, sorts and merges; why it is O(n log n); and when to choose it.&lt;br/&gt;&lt;br/&gt;Read the full article:&lt;blockquote class=&#34;border-l-05rem border-l-strongpink border-solid&#34;&gt;&lt;div class=&#34;-ml-4 bg-gradient-to-r from-gray-100 dark:from-zinc-800 to-transparent mr-0 mt-0 mb-4 pl-4 pr-2 py-2&#34;&gt;quoting  &lt;span itemprop=&#34;mentions&#34; itemscope itemtype=&#34;https://schema.org/Article&#34;&gt;&lt;a itemprop=&#34;url&#34; href=&#34;/naddr1qqt4gj2s95crxd6qxgcryd3dxycz6vfs2scn2vesqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hszrthwden5te0dehhxtnvdakqz9nhwden5te0wfjkccte9ec8y6tdv9kzumn9wspzpe52pptwjrvej7clwg0fq5jf39jp9h2hqwv6npajar74ul70ugneqvzqqqr4guzlnuje&#34; class=&#34;bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1&#34;&gt;naddr1qq…nuje&lt;/a&gt;&lt;/span&gt;&lt;br/&gt; &lt;/div&gt; &lt;h2 id=&#34;merge-sort-step-by-step&#34;&gt;Merge sort, step by step&lt;/h2&gt;

&lt;p&gt;Merge sort is the classic &lt;strong&gt;divide and conquer&lt;/strong&gt; sort.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Divide:&lt;/strong&gt; split the array into two halves.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conquer:&lt;/strong&gt; sort each half, with merge sort again (recursion).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Combine:&lt;/strong&gt; merge the two sorted halves into one sorted array.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An array of one item is already sorted, so the recursion stops there.&lt;/p&gt;

&lt;h3 id=&#34;the-code&#34;&gt;The code&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;Console.WriteLine(string.Join(&amp;#34; &amp;#34;, Sort(new[] { 5, 2, 9, 1, 6 })));
static int[] Sort(int[] a)
{
    if (a.Length &amp;lt;= 1) return a;
    int[] left = Sort(a[..(a.Length / 2)]), right = Sort(a[(a.Length / 2)..]); // split in half
    var result = new List&amp;lt;int&amp;gt;(); int i = 0, j = 0;
    while (i &amp;lt; left.Length &amp;amp;&amp;amp; j &amp;lt; right.Length) result.Add(left[i] &amp;lt;= right[j] ? left[i&#43;&#43;] : right[j&#43;&#43;]);
    result.AddRange(left[i..]); result.AddRange(right[j..]); // copy what is left
    return result.ToArray();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It prints &lt;code&gt;1 2 5 6 9&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&#34;merging&#34;&gt;Merging&lt;/h3&gt;

&lt;p&gt;Look only at the front of each half and take the smaller item. Repeat until one half is empty, then copy what is left of the other. Using &lt;code&gt;&amp;lt;=&lt;/code&gt; keeps equal items in their original order, so merge sort is &lt;strong&gt;stable&lt;/strong&gt;.&lt;/p&gt;

&lt;h3 id=&#34;cost&#34;&gt;Cost&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Time:&lt;/strong&gt; O(n log n) in every case. There are about log n levels of splitting, and each level merges n items in total.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory:&lt;/strong&gt; O(n) extra for the merged arrays.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&#34;when-to-choose-it&#34;&gt;When to choose it&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You need a &lt;strong&gt;stable&lt;/strong&gt; sort.&lt;/li&gt;
&lt;li&gt;You sort a &lt;strong&gt;linked list&lt;/strong&gt; (merging needs no random access).&lt;/li&gt;
&lt;li&gt;The data is too big for memory and is sorted in chunks on disk (external sorting).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In everyday C#, &lt;code&gt;Array.Sort&lt;/code&gt; is O(n log n) and the right default, but it is &lt;strong&gt;not stable&lt;/strong&gt;; &lt;code&gt;OrderBy&lt;/code&gt; in LINQ is stable. Know merge sort for interviews and for the cases above.&lt;/p&gt;

&lt;p&gt;Read more: &lt;a href=&#34;https://www.geeksforgeeks.org/dsa/merge-sort/&#34;&gt;https://www.geeksforgeeks.org/dsa/merge-sort/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;#tip · TIP-037&lt;/p&gt;
 &lt;/blockquote&gt;&lt;br/&gt;#tip · TIP-037
    </content>
    <updated>2026-10-10T12:38:01Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsydr9k2jvr5tymr9355zeelvga0uf2a2ld6jercxdr5ty73wvjzvqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j55x77s</id>
    
      <title type="html">Learn: Strategy Put each version of an algorithm behind the same ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsydr9k2jvr5tymr9355zeelvga0uf2a2ld6jercxdr5ty73wvjzvqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j55x77s" />
    <content type="html">
      Learn: Strategy&lt;br/&gt;&lt;br/&gt;Put each version of an algorithm behind the same shape, and choose one at run time. No growing if/else chain.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;Func&amp;lt;decimal, decimal&amp;gt; blackFriday = p =&amp;gt; p * 0.7m;&lt;br/&gt;Console.WriteLine(Checkout(100m, blackFriday));&lt;br/&gt;&lt;br/&gt;static decimal Checkout(decimal price, Func&amp;lt;decimal, decimal&amp;gt; discount) =&amp;gt; discount(price);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 70.0 (decimal keeps one decimal place from 0.7).&lt;br/&gt;In C#, a strategy can be an interface or just a Func. Use it for pricing rules, sorting orders, payment methods.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://www.geeksforgeeks.org/system-design/strategy-pattern-set-1/&#34;&gt;https://www.geeksforgeeks.org/system-design/strategy-pattern-set-1/&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-053
    </content>
    <updated>2026-10-10T10:37:56Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqs0rua6klmr4rdx45je77se3l9gl6p4zr88ha4yd6j6syw36xnaf7czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jul2xnm</id>
    
      <title type="html">Question: In the partition code, why is the line rt.Next = null ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqs0rua6klmr4rdx45je77se3l9gl6p4zr88ha4yd6j6syw36xnaf7czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jul2xnm" />
    <content type="html">
      Question: In the partition code, why is the line rt.Next = null needed? What goes wrong without it?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#ll008 · LL-008-Q2
    </content>
    <updated>2026-10-10T08:08:06Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsv3tdy5az7gp5zpeam8g0j0epd26y82c73n0er5x9anup6sn8cjgqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jht00w4</id>
    
      <title type="html">Question: The one-pass solution always looks at prev.Next, not at ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsv3tdy5az7gp5zpeam8g0j0epd26y82c73n0er5x9anup6sn8cjgqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jht00w4" />
    <content type="html">
      Question: The one-pass solution always looks at prev.Next, not at the current node itself. Why?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#ll005 · LL-005-Q3
    </content>
    <updated>2026-10-10T06:07:55Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqs8vvw84d93y99way230pqarla6avhtjknttsxtvmjlcd67al3549czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j52gmp5</id>
    
      <title type="html">Learn: Deadlock Thread 1 holds lock A and waits for B. Thread 2 ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqs8vvw84d93y99way230pqarla6avhtjknttsxtvmjlcd67al3549czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j52gmp5" />
    <content type="html">
      Learn: Deadlock&lt;br/&gt;&lt;br/&gt;Thread 1 holds lock A and waits for B. Thread 2 holds B and waits for A. Both wait forever.&lt;br/&gt;It needs four things at once:&lt;br/&gt;1. Only one thread can hold a lock.&lt;br/&gt;2. A thread holds one lock while it waits for another.&lt;br/&gt;3. Nobody can take a lock away.&lt;br/&gt;4. The waiting forms a circle.&lt;br/&gt;Prevent it: take locks in the same order, hold them briefly, use timeouts (Monitor.TryEnter).&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/standard/threading/managed-threading-best-practices&#34;&gt;https://learn.microsoft.com/en-us/dotnet/standard/threading/managed-threading-best-practices&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-079
    </content>
    <updated>2026-10-09T16:32:44Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsgf5xypy6pshpnk9whyvwcu3lpqe64js6h7a449a04z6en4hyqdkqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j2qmvws</id>
    
      <title type="html">Question: Two numbers are stored as linked lists, one digit per ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsgf5xypy6pshpnk9whyvwcu3lpqe64js6h7a449a04z6en4hyqdkqzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j2qmvws" />
    <content type="html">
      Question: Two numbers are stored as linked lists, one digit per node, with the ones digit first. 3 → 4 → 8 is 843 and 9 → 6 is 69.&lt;br/&gt;&lt;br/&gt;Return their sum as a list in the same format.&lt;br/&gt;&lt;br/&gt;(CtCI 2.5)&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#ll009 · LL-009-Q1
    </content>
    <updated>2026-10-09T12:07:31Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsfsj2xwe89yz09ja36pypjyevav6ststy0ngyvqja79u4uyfvd9agzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jyanf94</id>
    
      <title type="html">Question: What happens in the k-th-to-last code if k is bigger ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsfsj2xwe89yz09ja36pypjyevav6ststy0ngyvqja79u4uyfvd9agzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jyanf94" />
    <content type="html">
      Question: What happens in the k-th-to-last code if k is bigger than the list? How do you guard against it?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#ll006 · LL-006-Q2
    </content>
    <updated>2026-10-09T10:07:48Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqs8wa70ll0wkny4gu32pvyu7thdfhfaf0hpnu024jht4wj88n8xs3gzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jajrql4</id>
    
      <title type="html">Learn: The dummy node trick When you build a linked list by ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqs8wa70ll0wkny4gu32pvyu7thdfhfaf0hpnu024jht4wj88n8xs3gzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jajrql4" />
    <content type="html">
      Learn: The dummy node trick&lt;br/&gt;&lt;br/&gt;When you build a linked list by appending, the first node is a special case: there is no tail yet.&lt;br/&gt;&lt;br/&gt;A dummy node removes that special case. Start with a fake node, append after it, and at the end return dummy.Next.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;var dummy = new Node(0, null);&lt;br/&gt;Node tail = dummy;&lt;br/&gt;foreach (int v in new[] { 5, 6, 7 }) tail = tail.Next = new Node(v, null);&lt;br/&gt;Print(dummy.Next);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 5 → 6 → 7. The dummy&amp;#39;s own value is never used.&lt;br/&gt;&lt;br/&gt;#ll008 · LL-008-N
    </content>
    <updated>2026-10-08T18:07:26Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqs9e2sny3tqex9a89eq9g6wtxxrdr9upgamp6lz7745cuy4nayv42qzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jt9mjwy</id>
    
      <title type="html">Learn: Async mistakes interviewers ask about async void: ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqs9e2sny3tqex9a89eq9g6wtxxrdr9upgamp6lz7745cuy4nayv42qzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jt9mjwy" />
    <content type="html">
      Learn: Async mistakes interviewers ask about&lt;br/&gt;&lt;br/&gt;async void: exceptions can&amp;#39;t be caught by the caller and can crash the app. Use async Task (only event handlers are async void).&lt;br/&gt;.Result or .Wait() in a request: blocks a pool thread; under load, thread-pool starvation.&lt;br/&gt;Ignoring CancellationToken: when the user leaves, the work keeps running. Pass the request&amp;#39;s token down.&lt;br/&gt;Task.Run in a controller: moves work to another pool thread and gains nothing.&lt;br/&gt;&lt;br/&gt;Read more: &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/&#34;&gt;https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#tip · TIP-068
    </content>
    <updated>2026-10-08T17:07:26Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqswkuzdcsf9s6ycnvlvkrjxh7v0e7q4actrvv8dm34a226z6fhs7hgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38juq8m30</id>
    
      <title type="html">Question: Reverse a linked list with recursion instead of a loop. ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqswkuzdcsf9s6ycnvlvkrjxh7v0e7q4actrvv8dm34a226z6fhs7hgzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38juq8m30" />
    <content type="html">
      Question: Reverse a linked list with recursion instead of a loop. What is the extra memory now?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#ll004 · LL-004-Q2
    </content>
    <updated>2026-10-08T16:07:30Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqspc3nncgv7v7xu2vhwqtaut3klkcakr09yd0ts3uwhk0v872cnvlczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j486a4p</id>
    
      <title type="html">Learn: Binary search in one post On a sorted array, look at the ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqspc3nncgv7v7xu2vhwqtaut3klkcakr09yd0ts3uwhk0v872cnvlczyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38j486a4p" />
    <content type="html">
      Learn: Binary search in one post&lt;br/&gt;&lt;br/&gt;On a sorted array, look at the middle. If the target is bigger, keep the right half; if smaller, the left half. Each step halves the range: O(log n).&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;int[] a = { 1, 3, 5, 7, 9, 11 };&lt;br/&gt;int target = 7, lo = 0, hi = a.Length - 1;&lt;br/&gt;while (lo &amp;lt;= hi)&lt;br/&gt;{&lt;br/&gt;    int mid = lo &#43; (hi - lo) / 2;&lt;br/&gt;    if (a[mid] == target) { Console.WriteLine(mid); break; }&lt;br/&gt;    if (a[mid] &amp;lt; target) lo = mid &#43; 1; else hi = mid - 1;&lt;br/&gt;}&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 3. Write mid as lo &#43; (hi - lo) / 2: plain (lo &#43; hi) / 2 can overflow an int on huge arrays.&lt;br/&gt;&lt;br/&gt;#tip · TIP-006
    </content>
    <updated>2026-10-08T15:07:22Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsp29v58cujazu0pfcsf4ldlcm9l4mq4pt78h29xkkm5lsd7yfntyszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jckmz0k</id>
    
      <title type="html">Question: n = 1,000,000. Code A has a loop over all items, and ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsp29v58cujazu0pfcsf4ldlcm9l4mq4pt78h29xkkm5lsd7yfntyszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jckmz0k" />
    <content type="html">
      Question: n = 1,000,000. Code A has a loop over all items, and inside it another loop over all items. Code B calls Array.Sort once, then loops over the items once.&lt;br/&gt;&lt;br/&gt;What is the Big-O of each, and which is faster?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#big004 · BIG-004-Q2
    </content>
    <updated>2026-10-08T14:07:29Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsdgkrxra445eu7xgvlsqggvc3wxw69ehzz3d8yqgmpt4kp72ccvdszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jmkjgf4</id>
    
      <title type="html">Build two lists while you walk: one for small values, one for the ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsdgkrxra445eu7xgvlsqggvc3wxw69ehzz3d8yqgmpt4kp72ccvdszyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jmkjgf4" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqsr5xfn5p9jkal4w8pvzys2ttx0u9fr67cdj2swl78p2ujs3ygcguqpz3mhxue69uhhyetvv9ujuerpd46hxtnfdup97snh&#39;&gt;nevent1q…7snh&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;Build two lists while you walk: one for small values, one for the rest. Each starts with a dummy node. At the end, link the small list to the rest.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;Node? cur = Build(7, 2, 9, 4, 5, 1);&lt;br/&gt;Node less = new(0, null), rest = new(0, null), lt = less, rt = rest;&lt;br/&gt;for (; cur != null; cur = cur.Next)&lt;br/&gt;    if (cur.Value &amp;lt; 5) lt = lt.Next = cur;&lt;br/&gt;    else rt = rt.Next = cur;&lt;br/&gt;rt.Next = null; // the last node may still link to an old neighbor&lt;br/&gt;lt.Next = rest.Next;&lt;br/&gt;Print(less.Next);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 2 → 4 → 1 → 7 → 9 → 5. O(n) time, and O(1) extra memory because the nodes are reused.&lt;br/&gt;&lt;br/&gt;#ll008 · LL-008-A1
    </content>
    <updated>2026-10-08T12:07:20Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqs83x6shrawfeqw03tgq7rrfh6h9ykkakpzwq97vzujkzpy7wfm30czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jy2fxmm</id>
    
      <title type="html">For each node, send a second pointer (a runner) through the rest ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqs83x6shrawfeqw03tgq7rrfh6h9ykkakpzwq97vzujkzpy7wfm30czyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jy2fxmm" />
    <content type="html">
      In reply to &lt;a href=&#39;/nevent1qqs8ch4h67c5fg6jq75ypxq7x9zhqkhcnxwmh7jmhx339svslcjw0jqpz3mhxue69uhhyetvv9ujuerpd46hxtnfdu09p6mh&#39;&gt;nevent1q…p6mh&lt;/a&gt;&lt;br/&gt;_________________________&lt;br/&gt;&lt;br/&gt;For each node, send a second pointer (a runner) through the rest of the list and skip every node with the same value.&lt;br/&gt;&lt;br/&gt;```csharp&lt;br/&gt;Node head = Build(3, 1, 3, 2, 1);&lt;br/&gt;for (Node? cur = head; cur != null; cur = cur.Next)&lt;br/&gt;    for (Node runner = cur; runner.Next != null; )&lt;br/&gt;        if (runner.Next.Value == cur.Value) runner.Next = runner.Next.Next;&lt;br/&gt;        else runner = runner.Next;&lt;br/&gt;Print(head);&lt;br/&gt;```&lt;br/&gt;&lt;br/&gt;It prints 3 → 1 → 2. O(n²) time, O(1) extra memory.&lt;br/&gt;&lt;br/&gt;#ll005 · LL-005-A2
    </content>
    <updated>2026-10-08T10:07:19Z</updated>
  </entry>

  <entry>
    <id>https://yabu.me/nevent1qqsqa266gdy0snjduuya5nl5ga3ls9r8ezcdknqtsu4e2xlv40kdc8gzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jk0k28m</id>
    
      <title type="html">Interviewer&amp;#39;s follow-up: &amp;#34;Now rotate it ...</title>
    
    <link rel="alternate" href="https://yabu.me/nevent1qqsqa266gdy0snjduuya5nl5ga3ls9r8ezcdknqtsu4e2xlv40kdc8gzyrng5zzkayxen9a37us7jpfynztyztw4wque4xrm968atelulc38jk0k28m" />
    <content type="html">
      Interviewer&amp;#39;s follow-up: &amp;#34;Now rotate it counterclockwise.&amp;#34; What changes?&lt;br/&gt;&lt;br/&gt;Try to answer before you open the reply.&lt;br/&gt;&lt;br/&gt;#arr011 · ARR-011-Q3
    </content>
    <updated>2026-10-08T08:07:35Z</updated>
  </entry>

</feed>