<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hassaan Shuja</title>
    <description>The latest articles on DEV Community by Hassaan Shuja (@shah_sahab_3167a8b4d9f4a1).</description>
    <link>https://dev.to/shah_sahab_3167a8b4d9f4a1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4270402%2F4fef2717-ef57-4793-9ebf-4ee2c51364b1.png</url>
      <title>DEV Community: Hassaan Shuja</title>
      <link>https://dev.to/shah_sahab_3167a8b4d9f4a1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shah_sahab_3167a8b4d9f4a1"/>
    <language>en</language>
    <item>
      <title>Python Debugging for CS Exams: Catching Bugs Before Production</title>
      <dc:creator>Hassaan Shuja</dc:creator>
      <pubDate>Sat, 28 Nov 2026 09:15:52 +0000</pubDate>
      <link>https://dev.to/shah_sahab_3167a8b4d9f4a1/python-debugging-for-cs-exams-catching-bugs-before-production-5c0m</link>
      <guid>https://dev.to/shah_sahab_3167a8b4d9f4a1/python-debugging-for-cs-exams-catching-bugs-before-production-5c0m</guid>
      <description>&lt;p&gt;Most Python exam points are lost not to syntax errors, but to silent logic bugs like mutable defaults and shallow copies. Learn a repeatable debugging workflow to catch them before you submit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Silent Python Bugs Cost You Exam Points
&lt;/h2&gt;

&lt;p&gt;In computer science exams, technical interviews, and automated grading platforms like Gradescope or Canvas, your Python code rarely fails with a loud SyntaxError. Instead, it runs cleanly and returns the wrong value on hidden edge cases. Whether you are tracing a recursive function on a multiple-choice quiz or building a data pipeline, catching bugs before production—or before hitting Submit—requires a systematic mental checklist.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Key takeaway: Treat every Python exam question like a production code review: trace variable state at the boundaries, isolate mutable objects, and verify loop invariants before trusting the output.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you are pressed for time during a timed lab or online assessment, manually stepping through 40 lines of nested loops is exhausting. Pairing a disciplined debugging workflow with AI HomeTutor lets you capture a tricky code snippet with QuickSnap OCR and immediately inspect the execution trace in Detailed Proof Mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 4-Step Python Debugging Workflow
&lt;/h2&gt;

&lt;p&gt;Instead of reading code from top to bottom and hoping the bug jumps out, use this four-step triage process.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Check Function Signatures and Default Arguments
&lt;/h2&gt;

&lt;p&gt;Python evaluates default argument values once when the function is defined, not each time the function is called. If a default argument is a mutable object like a list or dict, every subsequent call shares the exact same object in memory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# BUGGY: Mutable default argument&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# ['a']&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# ['a', 'b'] &amp;lt;-- Unexpected!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Fix: Always default to None and initialize the container inside the function body:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Trace Loop Boundaries and Off-by-One Errors
&lt;/h2&gt;

&lt;p&gt;Exam writers love testing range(len(arr)) versus range(len(arr) - 1) and slice notation arr[start:end]. Remember that Python slices are inclusive of &lt;code&gt;start&lt;/code&gt; and exclusive of &lt;code&gt;end&lt;/code&gt;, and negative indices count backward from the end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When tracing a loop, write down the exact values of the index and accumulator for three moments:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First iteration (i = 0)&lt;br&gt;
Middle iteration (i = 1)&lt;br&gt;
Final iteration (i = len(arr) - 1)&lt;/p&gt;

&lt;p&gt;If you are unsure whether a complex nested loop terminates cleanly, you can use the &lt;a href="https://siriusrevenue.com/#extension" rel="noopener noreferrer"&gt;AI HomeTutor Chrome Extension to snap the code&lt;/a&gt; block directly from your browser tab and ask for a line-by-line state table.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Separate Shallow Copies from Deep Copies
&lt;/h2&gt;

&lt;p&gt;Assigning b = a in Python does not copy a list; it creates a second reference to the same list in memory. Even b = a.copy() or b = a[:] only creates a shallow copy—meaning nested lists or dictionaries inside a are still shared.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8dq4c2cs56606tii2em0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8dq4c2cs56606tii2em0.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Verify Variable Scope (LEGB Rule)
&lt;/h2&gt;

&lt;p&gt;Python resolves variable names using the LEGB rule: Local, Enclosing, Global, Built-in. A classic MCQ trap occurs when a function tries to modify a global variable without the global keyword, triggering an UnboundLocalError.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Python sees assignment 'count =' and treats count as local&lt;/span&gt;
    &lt;span class="c1"&gt;# Reading it before assignment raises UnboundLocalError&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Worked Example: Tracing a Tricky Recursion &amp;amp; Slicing MCQ
&lt;/h2&gt;

&lt;p&gt;Consider this classic CS1/CS2 exam question:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;mystery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;
    &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mystery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mystery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;mystery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step-by-Step Trace:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Split 1:&lt;/strong&gt; nums = [4, 2, 7, 1], mid = 2. left gets mystery([4, 2]), right gets mystery([7, 1]).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Left Branch:&lt;/strong&gt; mystery([4, 2]) splits into [4] and [2]. Since 4 &amp;lt; 2 is False, it returns [2] + [4] = [2, 4].&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Right Branch:&lt;/strong&gt; mystery([7, 1]) splits into [7] and [1]. Since 7 &amp;lt; 1 is False, it returns [1] + [7] = [1, 7].&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Merge:&lt;/strong&gt; Now left = [2, 4] and right = [1, 7]. The condition left[0] &amp;lt; right[0] checks 2 &amp;lt; 1, which is False. It returns right + left = [1, 7, 2, 4].&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Notice&lt;/strong&gt; how the function looks like Merge Sort at first glance, but it only compares the first elements! Skimming instead of tracing would lead you straight into choosing [1, 2, 4, 7].&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Exam Traps &amp;amp; How to Avoid Them
&lt;/h2&gt;

&lt;p&gt;Use this quick checklist before locking in any Python answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Integer Division vs. Float Division: In Python 3, / always returns a float (4 / 2 == 2.0), while // performs floor division (-5 // 2 == -3, not 2!).&lt;/li&gt;
&lt;li&gt;Modifying a List While Iterating: Never add or remove items from a list while looping over it with for x in my_list:. Iterate over a copy (my_list[:]) or build a new list with a comprehension.&lt;/li&gt;
&lt;li&gt;Dictionary Key Errors: Accessing d[key] raises a KeyError if the key is missing. Use d.get(key, default) when counting frequencies.&lt;/li&gt;
&lt;li&gt;Boolean Short-Circuiting: a and b returns a if a is falsy, otherwise b. a or b returns a if a is truthy, otherwise b.&lt;/li&gt;
&lt;li&gt;String Immutability: Strings cannot be modified in place (s[0] = 'A' raises a TypeError).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Speeding Up Your Study Workflow with AI HomeTutor
&lt;/h2&gt;

&lt;p&gt;When you are practicing past exams or debugging a stubborn lab assignment, you do not always have time to set up a local IDE with breakpoints. With AI HomeTutor, you can highlight or snap any Python snippet right inside your browser using QuickSnap OCR or Ctrl+V paste.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Direct Answer Mode&lt;/strong&gt;: Ideal for quickly verifying the output of a short trace question while drilling practice sets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Detailed Proof Mode&lt;/strong&gt;: Walks you through every recursive call, variable mutation, and edge case so you actually learn the underlying logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexible Model Routing&lt;/strong&gt;: Built-in Tutor Vision 4 works out of the box with no API key required. If you want to compare explanations across models, Pro and Ultra users can also route through personal API keys for GPT-5.4, Claude Sonnet 5.5, or DeepSeek V4.1—check out AI HomeTutor Pricing for Free, Pro, and Ultra Student Pass details.&lt;/p&gt;

&lt;p&gt;For more exam-day strategies across STEM subjects, explore our guides on &lt;a href="https://siriusrevenue.com/blog/mastering-statistics-mcqs-probability-traps" rel="noopener noreferrer"&gt;Mastering Statistics MCQs: Avoiding Common Probability &amp;amp; Distribution Traps&lt;/a&gt; and &lt;a href="https://siriusrevenue.com/blog/how-to-study-for-chemistry-in-high-school-2026-guide" rel="noopener noreferrer"&gt;How to Study for High School Chemistry: 2026-2027 Exam &amp;amp; Lab Guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Related Study Guides &amp;amp; Next Steps&lt;br&gt;
Related Study Guide: &lt;a href="https://siriusrevenue.com/blog/mastering-chemistry-olympiad-exam-strategies" rel="noopener noreferrer"&gt;Mastering the Chemistry Olympiad: Exam Strategies and Problem Solving&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why does Python raise an UnboundLocalError when I modify a global variable inside a function?&lt;/strong&gt;&lt;br&gt;
If you assign a value to a variable anywhere inside a function, Python treats that variable as local to the function. Trying to read it before the local assignment completes (such as with &lt;code&gt;count += 1&lt;/code&gt;) raises an UnboundLocalError unless you declare &lt;code&gt;global count&lt;/code&gt; first.&lt;/p&gt;

&lt;p&gt;Published by&lt;/p&gt;

&lt;p&gt;&lt;a href="https://siriusrevenue.com" rel="noopener noreferrer"&gt;AI HomeTutor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://siriusrevenue.com/blog" rel="noopener noreferrer"&gt;Practical STEM study guides, visual OCR note-review strategies, and step-by-step tutoring resources for learners.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Debugging SQL Window Functions, Recursion &amp; Complexity Traps with Code Mode</title>
      <dc:creator>Hassaan Shuja</dc:creator>
      <pubDate>Sat, 28 Nov 2026 08:57:43 +0000</pubDate>
      <link>https://dev.to/shah_sahab_3167a8b4d9f4a1/debugging-sql-window-functions-recursion-complexity-traps-with-code-mode-326e</link>
      <guid>https://dev.to/shah_sahab_3167a8b4d9f4a1/debugging-sql-window-functions-recursion-complexity-traps-with-code-mode-326e</guid>
      <description>&lt;p&gt;&lt;strong&gt;Reader Summary&lt;/strong&gt;&lt;br&gt;
Topic: AI code debugger chrome extension&lt;br&gt;
See how Computer Science students use AI HomeTutor Code Mode to fix SQL GROUP BY traps, Big-O dynamic programming recurrences, and Python edge cases inside Chrome.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Why Passing Sample Cases Still Fails Hidden Test Suites&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Browser-based CS assessments (HackerRank, Codility, StrataScratch, and university auto-graders) usually expose only two trivial sample tests while grading against 12+ hidden edge cases: empty tables, NULL join keys, duplicate ties, or 10^5-element inputs that trigger Time Limit Exceeded (TLE).&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Fixing Classic SQL Window Function Traps
&lt;/h2&gt;

&lt;p&gt;A frequent database exam question asks: "Return the second-highest distinct salary per department, returning NULL if a department only has one salary."&lt;/p&gt;

&lt;p&gt;Students often write ROW_NUMBER() instead of DENSE_RANK(), failing silently whenever two employees tie for top salary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;ranked_salaries&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="n"&gt;department_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nb"&gt;DENSE_RANK&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;OVER&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="k"&gt;PARTITION&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;department_id&lt;/span&gt;
      &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;rnk&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;department_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;MAX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;CASE&lt;/span&gt; &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rnk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt; &lt;span class="k"&gt;END&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;second_highest_salary&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;departments&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;ranked_salaries&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;department_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Snap the table schema diagram plus prompt text in AI HomeTutor Code Mode, and the output immediately flags DENSE_RANK() vs ROW_NUMBER() alongside LEFT JOIN preservation for single-employee departments.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Spotting Hidden Time-Complexity Bottlenecks in Python
&lt;/h2&gt;

&lt;p&gt;Another common CS exam trap is slicing a list or running x in list inside a loop, turning an intended O(n) sliding-window solution into O(n^2):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;longest_unique_subarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;
        &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Pre-Submit Code Audit Checklist
&lt;/h2&gt;

&lt;p&gt;SQL: Check WHERE vs HAVING, NULL semantics in NOT IN, and tie-breaking rules (RANK vs DENSE_RANK).&lt;br&gt;
Algorithms: Verify empty array (len == 0), single-element input, negative integers, and recursion depth limits.&lt;br&gt;
Big-O Discipline: Pair Code Mode with DeepSeek V4.1 or Claude Sonnet 5.5 (Pro/Ultra BYOK) when optimizing tight dynamic programming transitions.&lt;br&gt;
Frequently Asked Questions&lt;/p&gt;

&lt;p&gt;Which model is best inside AI HomeTutor for SQL and Python assessments?&lt;br&gt;
Built-in Tutor Vision 4 reads ER diagrams and screenshot stack traces accurately, while Claude Sonnet 5.5 and DeepSeek V4.1 (Pro/Ultra BYOK) shine on complex multi-file debugging and Big-O optimization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can AI HomeTutor explain why my code failed a hidden edge case instead of rewriting everything?
&lt;/h2&gt;

&lt;p&gt;Yes. Paste your current attempt alongside the problem description—Code Mode pinpoints the exact failing invariant or SQL join bug first.&lt;/p&gt;

&lt;p&gt;Published by&lt;/p&gt;

&lt;p&gt;AI HomeTutor&lt;/p&gt;

&lt;p&gt;Practical STEM study guides, visual OCR note-review strategies, and step-by-step tutoring resources for learners.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
