<?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>Forem: ZhiHong Chua</title>
    <description>The latest articles on Forem by ZhiHong Chua (@c6z3h).</description>
    <link>https://forem.com/c6z3h</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F746749%2F56ed9be5-524a-4255-b8d9-fe4e30f9a7ab.jpg</url>
      <title>Forem: ZhiHong Chua</title>
      <link>https://forem.com/c6z3h</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/c6z3h"/>
    <language>en</language>
    <item>
      <title>Stop Burning Cash: Real-World Lessons in LLM Token Optimisation</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Fri, 07 Nov 2025 12:11:58 +0000</pubDate>
      <link>https://forem.com/c6z3h/stop-burning-cash-real-world-lessons-in-llm-token-optimisation-3jic</link>
      <guid>https://forem.com/c6z3h/stop-burning-cash-real-world-lessons-in-llm-token-optimisation-3jic</guid>
      <description>&lt;p&gt;There is immense hype around AI, but the real work is in making it efficient and cost-effective. This week, I had a great conversation with a friend about integrating AI into their family business, and the first barrier we hit was ensuring that deployment costs wouldn't swallow their budget.&lt;/p&gt;

&lt;p&gt;My recent experiments in optimising Large Language Model (LLM) calls revealed critical lessons on balancing performance with operational expenditure. Here are my key findings on drastically reducing token usage and navigating API vendor choices.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Cost Efficiency: Cutting Token Consumption by 87%
&lt;/h2&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.amazonaws.com%2Fuploads%2Farticles%2Fx5wx0cpv7xpj9mqswmri.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.amazonaws.com%2Fuploads%2Farticles%2Fx5wx0cpv7xpj9mqswmri.png" alt="Initial Cost" width="800" height="584"&gt;&lt;/a&gt;&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.amazonaws.com%2Fuploads%2Farticles%2Fp2gway8u5s6cihiyu0pr.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.amazonaws.com%2Fuploads%2Farticles%2Fp2gway8u5s6cihiyu0pr.png" alt="Final Cost" width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The goal of implementing AI tools is to harness their ability to scale content production while maintaining a lower operational cost approach. In one workflow, I managed to reduce the average token usage from 4,000 tokens per request down to approximately 500. This efficiency demonstrates the power of integrating human creativity and strategic thinking with AI.&lt;/p&gt;

&lt;p&gt;Here is the strategic breakdown of how this massive reduction was achieved:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Isolation of Deterministic Logic: The initial cut involved isolating any logic that could be handled purely by the backend. This step ensures that the LLM is only used for tasks requiring true natural language understanding or generation, reducing the prompt size significantly.&lt;/li&gt;
&lt;li&gt;Reliance on Model Training Data: The second optimisation involved relying more heavily on the AI model's existing training data. Instead of providing extensive examples or foundational knowledge (which consumes tokens), the process focused on maintaining local context relevant to the current conversation rather than providing unnecessarily global context.&lt;/li&gt;
&lt;li&gt;Implementing Intent Classification: Where minimal context was available, it became necessary to implement intent classification. This addition allows the system to accurately direct the query, even when the context provided to the model is small, thus preventing ambiguous results or expensive, irrelevant generations.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  2. Strategic API Choice: Hugging Face vs. OpenAI
&lt;/h2&gt;

&lt;p&gt;Here is a practical comparison based on testing:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Hugging Face Inference API&lt;/th&gt;
&lt;th&gt;OpenAI API (e.g., GPT models)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cost Model&lt;/td&gt;
&lt;td&gt;Offers a free tier (up to 10 cents, periodically resetting, approximately once a week)&lt;/td&gt;
&lt;td&gt;Generally requires payment; lacks a substantial free trial&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best Use Case&lt;/td&gt;
&lt;td&gt;Excellent for small-scale testing and validating concepts due to the minimal initial cost&lt;/td&gt;
&lt;td&gt;Best for maintaining large context efficiently in chat sessions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context Handling&lt;/td&gt;
&lt;td&gt;Requires the initial prompt (the system message/context) to be sent with each request (which becomes costly if your context is large)&lt;/td&gt;
&lt;td&gt;The initial large prompt can typically be sent once only at the start of the chat session, improving efficiency and reducing recurring token expenditure&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  3. Looking Forward: The Move to Agentic AI
&lt;/h2&gt;

&lt;p&gt;While some may categorize this optimization work strictly within the realm of generative AI, the course I completed with Vanderbilt University suggests that the field is rapidly moving toward agentic AI.&lt;/p&gt;

&lt;p&gt;My objective is to push my knowledge deeper into agentic AI soon, focusing on building systems that can actively plan and execute tasks to deliver higher-order value!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>performance</category>
      <category>openai</category>
    </item>
    <item>
      <title>Week 19: Halibut</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Mon, 09 Jun 2025 02:22:28 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-19-halibut-56ne</link>
      <guid>https://forem.com/c6z3h/week-19-halibut-56ne</guid>
      <description>&lt;p&gt;Why halibut? It's just a random name 😂&lt;/p&gt;

&lt;h2&gt;
  
  
  1. JS Quiz
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - &lt;a href="https://www.simplilearn.com/tutorials/nodejs-tutorial/what-is-nodejs#why_do_we_use_nodejs" rel="noopener noreferrer"&gt;What is NodeJS&lt;/a&gt;. A runtime environment for JS&lt;/li&gt;
&lt;li&gt;WED -&lt;a href="https://cyberscope.medium.com/web3-security-compliance-a-complete-guide-e1f9d2aa998c" rel="noopener noreferrer"&gt;Compliance in Web3&lt;/a&gt;. How to enforce, in an open economy, sanctions and blocking funding of terrorists, and thorough code review? Memory leak from &lt;code&gt;useEffect&lt;/code&gt; and &lt;code&gt;setInterval&lt;/code&gt;. &lt;code&gt;this&lt;/code&gt; in traditional vs arrow functions&lt;/li&gt;
&lt;li&gt;THU - “display: none = None at all. Others = still takes space.”, &lt;strong&gt;Reading&lt;/strong&gt; layout (eg. offsetHeight) forces the browser to "flush the pipeline" to give you a correct value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Behaviour (3 daily)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;MON&lt;/th&gt;
&lt;th&gt;TUE&lt;/th&gt;
&lt;th&gt;WED&lt;/th&gt;
&lt;th&gt;THU&lt;/th&gt;
&lt;th&gt;FRI&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2 (live)&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4 (live)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  3. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - &lt;a href="https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/description/?envType=daily-question&amp;amp;envId=2025-06-09" rel="noopener noreferrer"&gt;K-th Smallest in Lexicographical Order&lt;/a&gt; Hard &lt;code&gt;Trie&lt;/code&gt; question. Interesting to observe this data structure being used on numbers. I was only exposed to using it on letters (i.e word search) before.&lt;/li&gt;
&lt;li&gt;TUE - &lt;a href="https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-i/?envType=daily-question&amp;amp;envId=2025-06-10" rel="noopener noreferrer"&gt;Maximum Difference Between Even and Odd Frequency I&lt;/a&gt; Easy &lt;code&gt;Hashmap&lt;/code&gt; question. Revised "Three Sum" &lt;code&gt;Two Pointer&lt;/code&gt; question!&lt;/li&gt;
&lt;li&gt;WED - &lt;a href="https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-ii/solutions/6831340/easiest-solution-detail-explanation-o-n-dp-sliding-window-prefix-sum/?envType=daily-question&amp;amp;envId=2025-06-11" rel="noopener noreferrer"&gt;Maximum Difference Between Even and Odd Frequency II&lt;/a&gt; &lt;code&gt;Bitmask&lt;/code&gt;, &lt;code&gt;Prefix Sum&lt;/code&gt;. Skipped the usual suspect (bitmask) part, but did 670 / 690 cases with the latter!&lt;/li&gt;
&lt;li&gt;THU - &lt;a href="https://leetcode.com/problems/maximum-difference-between-adjacent-elements-in-a-circular-array/description/?envType=daily-question&amp;amp;envId=2025-06-12" rel="noopener noreferrer"&gt;Maximum Difference Between Adjacent Elements in a Circular Array&lt;/a&gt; Easy &lt;code&gt;Array&lt;/code&gt; question&lt;/li&gt;
&lt;li&gt;FRI - &lt;a href="https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/submissions/1663163194/?envType=daily-question&amp;amp;envId=2025-06-13" rel="noopener noreferrer"&gt;Minimize the Maximum Difference of Pairs&lt;/a&gt; very interesting application of &lt;code&gt;Binary Search&lt;/code&gt;, Medium.&lt;/li&gt;
&lt;li&gt;SAT - &lt;a href="https://leetcode.com/problems/maximum-difference-by-remapping-a-digit/description/?envType=daily-question&amp;amp;envId=2025-06-13" rel="noopener noreferrer"&gt;Maximum Difference by Remapping a Digit&lt;/a&gt;. An Easy &lt;code&gt;Greedy&lt;/code&gt; question but edge cases threw me off a little.&lt;/li&gt;
&lt;li&gt;SUN - &lt;a href="https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer/description/?envType=daily-question&amp;amp;envId=2025-06-13" rel="noopener noreferrer"&gt;Max Difference You Can Get From Changing an Integer&lt;/a&gt; Medium &lt;code&gt;Greedy&lt;/code&gt; question.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - another 7 questions on Edabit (to be honest, it's more like Leetcode than JS questions like flatten array, but let's take it for today)&lt;/li&gt;
&lt;li&gt;TUE - &lt;code&gt;Data Merging&lt;/code&gt; and &lt;code&gt;Holy Grail&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;WED - &lt;code&gt;Flatten&lt;/code&gt; in actual setting! and &lt;code&gt;Throttle&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;THU - &lt;code&gt;Flatten&lt;/code&gt;, &lt;code&gt;Debounce&lt;/code&gt;, and &lt;code&gt;Deep Clone&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;FRI - (live) diff 2 objects&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. System Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;WED - 📦 System Design Prompt: Design a File Upload System with Preview&lt;/li&gt;
&lt;li&gt;FRI - (live) generic interface for a form&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>leetcode</category>
      <category>coding</category>
    </item>
    <item>
      <title>Week 18: Busy with Life</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Mon, 02 Jun 2025 08:56:00 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-18-busy-with-life-36em</link>
      <guid>https://forem.com/c6z3h/week-18-busy-with-life-36em</guid>
      <description>&lt;p&gt;Many things coming up in life, going to tone this down a little, but still, for journal's sake!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. JS Quiz
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - Questions 11 - 20 in importance. Event Loop, this, event delegation&lt;/li&gt;
&lt;li&gt;TUE - all other questions. Closure, hooks&lt;/li&gt;
&lt;li&gt;THU - &lt;a href="https://www.browserstack.com/guide/common-cross-browser-compatibility-issues" rel="noopener noreferrer"&gt;Top 10 Cross Browser Issues&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;FRI - &lt;code&gt;useState&lt;/code&gt; vs &lt;code&gt;Animated.View&lt;/code&gt; for optimum progress bar animation rendering&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Behaviour (3 daily)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;MON&lt;/th&gt;
&lt;th&gt;TUE&lt;/th&gt;
&lt;th&gt;WED&lt;/th&gt;
&lt;th&gt;THU&lt;/th&gt;
&lt;th&gt;FRI&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  3. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - Hard question. Took quick look&lt;/li&gt;
&lt;li&gt;TUE - &lt;a href="https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes/description/?envType=daily-question&amp;amp;envId=2025-05-29" rel="noopener noreferrer"&gt;Maximum Candies You Can Get from Boxes&lt;/a&gt; Hard &lt;code&gt;Graph&lt;/code&gt;, and &lt;code&gt;BFS&lt;/code&gt; question.&lt;/li&gt;
&lt;li&gt;WED - &lt;a href="https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/description/?envType=daily-question&amp;amp;envId=2025-05-29" rel="noopener noreferrer"&gt;Find the Lexicographically Largest String From the Box I&lt;/a&gt; Medium &lt;code&gt;Enumeration&lt;/code&gt; question. That was tricky&lt;/li&gt;
&lt;li&gt;THU - &lt;a href="https://leetcode.com/problems/lexicographically-smallest-equivalent-string/description/?envType=daily-question&amp;amp;envId=2025-05-29" rel="noopener noreferrer"&gt;Lexicographically Smallest Equivalent String&lt;/a&gt; &lt;code&gt;Union Find&lt;/code&gt;. Looks like I'm a bit rusty with implementation&lt;/li&gt;
&lt;li&gt;FRI - &lt;a href="https://leetcode.com/problems/using-a-robot-to-print-the-lexicographically-smallest-string/editorial/?envType=daily-question&amp;amp;envId=2025-06-06" rel="noopener noreferrer"&gt;Using a Robot to Print the Lexicographically Smallest String&lt;/a&gt; Medium &lt;code&gt;Stack&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;SAT - &lt;a href="https://leetcode.com/problems/lexicographically-minimum-string-after-removing-stars/editorial/?envType=daily-question&amp;amp;envId=2025-06-06" rel="noopener noreferrer"&gt;Lexicographically Minimum String After Removing Stars&lt;/a&gt; completed a trivial solution of &lt;code&gt;Greedy&lt;/code&gt; Medium question. My solution was O(N) space, O(N^2) time. Optimised answer is O(N^2) space, O(N) time.&lt;/li&gt;
&lt;li&gt;SUN - &lt;a href="https://leetcode.com/problems/lexicographical-numbers/description/?envType=daily-question&amp;amp;envId=2025-06-08" rel="noopener noreferrer"&gt;Lexicographical Numbers&lt;/a&gt; Medium &lt;code&gt;DFS&lt;/code&gt; with a twist. This required understanding of what lexicographical numbers meant, such as this being the sorting order... &lt;code&gt;1,10,100,101,102,103,104,105,106,107,108,109,11,110,111,112,113,114...&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - &lt;code&gt;useSet&lt;/code&gt; hook, &lt;code&gt;mean&lt;/code&gt; js&lt;/li&gt;
&lt;li&gt;FRI - &lt;code&gt;useState&lt;/code&gt; vs &lt;code&gt;Animated.View&lt;/code&gt; for optimum progress bar animation rendering&lt;/li&gt;
&lt;li&gt;SAT - seven questions on Edabit&lt;/li&gt;
&lt;li&gt;SUN - 10 / 10 questions on &lt;a href="https://dev.to/frontendengineer/10-reactjs-coding-exercises-with-codepen-exercise-and-solution--22k7"&gt;Binance's recommended JS questions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. System Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - 🧩 Scenario: Build a Customizable Dashboard for Airline Crew&lt;/li&gt;
&lt;li&gt;TUE - 🛫 Design a Flight Booking Page (Multi-step Form System)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>coding</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>Week 17: Four months in</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Mon, 26 May 2025 04:56:50 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-17-four-months-in-49hk</link>
      <guid>https://forem.com/c6z3h/week-17-four-months-in-49hk</guid>
      <description>&lt;p&gt;I think I've been jumping all over the place! The last week I seriously started getting into a few things&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;building an Astro side project to learn SSR&lt;/li&gt;
&lt;li&gt;exploring work CI pipeline to see how I could optimise&lt;/li&gt;
&lt;li&gt;considering exploring BFF to learn BE skills
so it starts to feel a bit crazy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the other hand, the last week was packed with matters outside of work, so the journal last week was a little sparse, but onward and upward!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. JS Quiz
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - Responsive Web Design, JS Fundamentals. Browser, Screen Size, Device, OS Compatibility.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;float&lt;/code&gt;, which happens to be useful for my work!&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;BrowserStack&lt;/code&gt; and &lt;code&gt;Selenium&lt;/code&gt; for automated UI testing&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;THU - CSS, Virtual DOM, Hoisting&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Behaviour (3 daily)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;MON&lt;/th&gt;
&lt;th&gt;TUE&lt;/th&gt;
&lt;th&gt;WED&lt;/th&gt;
&lt;th&gt;THU&lt;/th&gt;
&lt;th&gt;FRI&lt;/th&gt;
&lt;th&gt;SAT&lt;/th&gt;
&lt;th&gt;SUN&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  3. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - &lt;a href="https://leetcode.com/problems/largest-color-value-in-a-directed-graph/submissions/1644675024/?envType=daily-question&amp;amp;envId=2025-05-19" rel="noopener noreferrer"&gt;Largest Color Value in a Directed Graph&lt;/a&gt;. Solved half the test cases (40/83) for this Hard &lt;code&gt;Graph&lt;/code&gt; question. Completed &lt;code&gt;Backtracking&lt;/code&gt; in 30 minutes. TLE-ed.&lt;/li&gt;
&lt;li&gt;TUE - &lt;a href="https://leetcode.com/problems/divisible-and-non-divisible-sums-difference/description/?envType=daily-question&amp;amp;envId=2025-05-27" rel="noopener noreferrer"&gt;Divisible and Non-divisible Sums Difference&lt;/a&gt; Easy question. Challenged myself to improve O(N) to O(1) by arithmetic progression formula. &lt;code&gt;Math&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;WED - &lt;a href="https://leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-i/editorial/?envType=daily-question&amp;amp;envId=2025-05-27" rel="noopener noreferrer"&gt;Maximize the Number of Target Nodes After Connecting Trees I&lt;/a&gt; Medium &lt;code&gt;Tree&lt;/code&gt;, &lt;code&gt;BFS&lt;/code&gt; question.&lt;/li&gt;
&lt;li&gt;FRI - &lt;a href="https://leetcode.com/problems/find-closest-node-to-given-two-nodes/description/?envType=daily-question&amp;amp;envId=2025-05-29" rel="noopener noreferrer"&gt;Find Closest Node to Given Two Nodes&lt;/a&gt; Medium &lt;code&gt;Graph&lt;/code&gt; and &lt;code&gt;BFS&lt;/code&gt; question. Confusing description, spent a lot of time.&lt;/li&gt;
&lt;li&gt;SUN - &lt;a href="https://leetcode.com/problems/distribute-candies-among-children-ii/editorial/?envType=daily-question&amp;amp;envId=2025-05-29" rel="noopener noreferrer"&gt;Distribute Candies Among Children II&lt;/a&gt; Medium &lt;code&gt;Math&lt;/code&gt; question. Mind boggling.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - &lt;code&gt;Promise.all&lt;/code&gt; (JS), &lt;code&gt;useDebounce&lt;/code&gt; (React), and &lt;code&gt;Todo List&lt;/code&gt; (UI)&lt;/li&gt;
&lt;li&gt;TUE - &lt;code&gt;Curry&lt;/code&gt; (JS), &lt;code&gt;useCycle&lt;/code&gt; (React), &lt;code&gt;Progress Bar&lt;/code&gt; (UI @ work)&lt;/li&gt;
&lt;li&gt;THU - &lt;code&gt;Contact Form&lt;/code&gt; (UI), &lt;code&gt;Data Merging&lt;/code&gt; (JS)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. System Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;THU - Real-time Notification System&lt;/li&gt;
&lt;li&gt;FRI - Collaborative Editor like Google Docs&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>astro</category>
      <category>cicd</category>
      <category>bff</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Week 16: One Moment of Silence</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Wed, 21 May 2025 01:50:05 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-16-one-moment-of-silence-59gf</link>
      <guid>https://forem.com/c6z3h/week-16-one-moment-of-silence-59gf</guid>
      <description>&lt;p&gt;Back to the drawing board again, it seems. The effort into this endeavour is huge, but the payoff seems distant.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. JS Quiz
&lt;/h2&gt;

&lt;h2&gt;
  
  
  2. Behaviour
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - practiced 3&lt;/li&gt;
&lt;li&gt;THU - done 3&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - Daily question&lt;/li&gt;
&lt;li&gt;TUE - Daily question. Medium, sweep-line prefix sum.&lt;/li&gt;
&lt;li&gt;WED - &lt;a href="https://leetcode.com/problems/set-matrix-zeroes/submissions/1639965039/?envType=daily-question&amp;amp;envId=2025-05-19" rel="noopener noreferrer"&gt;Set Matrix Zeroes&lt;/a&gt;. Medium &lt;code&gt;Matrix&lt;/code&gt; question. O(M*N) time. O(M+N) space achieved, didn't figure the O(1) space solution... though it seemed a bit extreme.&lt;/li&gt;
&lt;li&gt;THU - &lt;a href="https://leetcode.com/problems/zero-array-transformation-iii/?envType=daily-question&amp;amp;envId=2025-05-19" rel="noopener noreferrer"&gt;Zero Array Transformation III&lt;/a&gt;. &lt;code&gt;Heap&lt;/code&gt; + &lt;code&gt;Prefix Sum&lt;/code&gt;, it's too difficult!&lt;/li&gt;
&lt;li&gt;SAT - easy question&lt;/li&gt;
&lt;li&gt;SUN - medium &lt;code&gt;Palindrome&lt;/code&gt; &lt;a href="https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words/description/?envType=daily-question&amp;amp;envId=2025-05-19" rel="noopener noreferrer"&gt;Longest Palindrome by Concatenating Two Letter Words&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. JS Coding
&lt;/h2&gt;

&lt;h2&gt;
  
  
  5. System Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TUE - analyse the existing pipeline's most recent 30 errors&lt;/li&gt;
&lt;li&gt;THU - first &lt;code&gt;SSR hydration&lt;/code&gt; component implemented on Astro! It sounds so technical, but just means a Javascript-infused HTML element / component.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>systemdesign</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Week 15: What</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Tue, 13 May 2025 05:36:53 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-15-what-254f</link>
      <guid>https://forem.com/c6z3h/week-15-what-254f</guid>
      <description>&lt;p&gt;A slow start after a long weekend&lt;/p&gt;

&lt;h2&gt;
  
  
  1. JS Quiz
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TUE - Did a &lt;a href="https://www.w3schools.com/quiztest/quiztest.asp?qtest=REACT" rel="noopener noreferrer"&gt;W3Schools React Quiz&lt;/a&gt;. Also viewed a &lt;a href="https://www.youtube.com/watch?v=ff0U4awBnmc" rel="noopener noreferrer"&gt;common React questions YouTube video&lt;/a&gt;. These raised a few interesting points such:

&lt;ul&gt;
&lt;li&gt;What happens when &lt;code&gt;useEffect&lt;/code&gt; dependencies is empty?&lt;/li&gt;
&lt;li&gt;Why is React designed with immutable state in mind?&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.dev/learn/keeping-components-pure" rel="noopener noreferrer"&gt;Why is Pure Component an important design pattern in React?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;WED - Reviewed past weeks' content, SEO and speed. Studied &lt;a href="https://react.dev/reference/rsc/server-components" rel="noopener noreferrer"&gt;Server Components&lt;/a&gt; too, seems it is like Astro Islands. But it seems a lot of effort for minor value... worked out a 4-week plan to investigate and implement projects that might have some value.&lt;/li&gt;

&lt;li&gt;FRI - Reviewed the past 30 CI pipelines. In-depth analysis to follow&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Behaviour
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TUE - revised 3 questions. Finding blind spots...&lt;/li&gt;
&lt;li&gt;WED - another 3&lt;/li&gt;
&lt;li&gt;THU - did 3&lt;/li&gt;
&lt;li&gt;FRI - speaking louder in practice instead of whisper feels good! Did 3.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TUE - &lt;a href="https://leetcode.com/problems/total-characters-in-string-after-transformations-i/description/?envType=daily-question&amp;amp;envId=2025-05-09" rel="noopener noreferrer"&gt;Total Characters in String After Transformations I&lt;/a&gt; had the &lt;code&gt;Medium, string&lt;/code&gt; solution, turns out they only wanted brute force, not optimised generic formula (it was hard to get to!)&lt;/li&gt;
&lt;li&gt;WED - &lt;a href="https://leetcode.com/problems/total-characters-in-string-after-transformations-ii/description/?envType=daily-question&amp;amp;envId=2025-05-09" rel="noopener noreferrer"&gt;Total Characters in String After Transformations II&lt;/a&gt;, at least got the brute force &lt;code&gt;Hard, string&lt;/code&gt; method working well!&lt;/li&gt;
&lt;li&gt;THU - &lt;a href="https://leetcode.com/problems/longest-unequal-adjacent-groups-subsequence-ii/description/" rel="noopener noreferrer"&gt;Longest Unequal Adjacent Groups Subsequence II&lt;/a&gt;. Breezed through the Easy version of this question and did this &lt;code&gt;Medium, backtracking&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;FRI - repeated the question yesterday, managed to pass the backtracking solution. Couldn't figure out the dynamic programming solution though. Practiced going from &lt;code&gt;recursion&lt;/code&gt; to &lt;code&gt;memoization&lt;/code&gt; to &lt;code&gt;dynamic programming&lt;/code&gt;! &lt;a href="https://leetcode.com/problems/house-robber/description/?envType=problem-list-v2&amp;amp;envId=dynamic-programming" rel="noopener noreferrer"&gt;House Robber&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;SAT - &lt;a href="https://leetcode.com/problems/sort-colors/description/?envType=daily-question&amp;amp;envId=2025-05-17" rel="noopener noreferrer"&gt;Sort Colors&lt;/a&gt; a Medium &lt;code&gt;sorting&lt;/code&gt; question. Learnt about the 3-pointer Dutch National Flag problem&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TUE - Setup astro website! Going to finish the tutorial tomorrow to make a working example of SSR &amp;amp; hydration.&lt;/li&gt;
&lt;li&gt;WED - Revised 2 questions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. System Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TUE - Subdomains. &lt;code&gt;en.wikipedia.org&lt;/code&gt; and &lt;code&gt;ads.google.com&lt;/code&gt; are both examples of sub-domains. Cloud servers can spin up and allocate the resources where required.&lt;/li&gt;
&lt;li&gt;WED - TODO: continue building the astro website&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>productivity</category>
      <category>coding</category>
    </item>
    <item>
      <title>Week 14: Momentum</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Mon, 05 May 2025 01:35:59 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-14-momentum-2bkm</link>
      <guid>https://forem.com/c6z3h/week-14-momentum-2bkm</guid>
      <description>&lt;p&gt;I don't know if I've been more hardworking after returning from holidays, or it so happened that the weeks of studying bits and pieces finally came together last week... I've finished some milestones in studying!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;JS Quiz - completed all high priority questions&lt;/li&gt;
&lt;li&gt;JS Coding - completed all relevant questions&lt;/li&gt;
&lt;li&gt;Behavioural - practiced speaking&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;System Design and Leetcode remains a little unstable, but I think we are getting better! This week will mostly focus on recap.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. JS Quiz
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - (15/63 revised) &lt;code&gt;box-sizing&lt;/code&gt;, &lt;code&gt;display&lt;/code&gt;, React, event loop, hoisting, event delegation, &lt;code&gt;this&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;mistakes: box-sizing measures? &lt;code&gt;position: relative&lt;/code&gt; means? What's &lt;code&gt;this&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;TUE - (42/63 revised) closure, constructors, cookies, Virtual DOM.

&lt;ul&gt;
&lt;li&gt;mistakes: CSS selectors? translate() vs absolute position? Event bubbling? Z-index?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;WED - 63 revised! What shall I explore tomorrow? Perhaps spend more time on weaker areas (Leetcode / JS Coding).

&lt;ul&gt;
&lt;li&gt;mistakes: HTTP Cache Headers?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;THU - Gemini-generated list of 15+ questions. Like &lt;code&gt;useLayoutEffect&lt;/code&gt; vs &lt;code&gt;useEffect&lt;/code&gt;, or &lt;code&gt;Error Boundary&lt;/code&gt;.

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://react.dev/reference/react/StrictMode" rel="noopener noreferrer"&gt;Strict Mode&lt;/a&gt; - wrap the root of app with this. Runs twice the ref / effects, to detect if forgot to cleanup.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/vishnusatheesh/controlled-and-uncontrolled-components-in-react-1me4"&gt;Controlled vs Uncontrolled Components&lt;/a&gt; is mainly difference in form state; whether use &lt;code&gt;form.submit()&lt;/code&gt; or &lt;code&gt;setData&lt;/code&gt;. Really is just up to preference...?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Behaviour
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - spoke 3!&lt;/li&gt;
&lt;li&gt;TWO - spoke 2! Speak on phone seems to work smoother&lt;/li&gt;
&lt;li&gt;WED - spoke 3! But could tighten answer&lt;/li&gt;
&lt;li&gt;THU - done 3&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - &lt;a href="https://leetcode.com/problems/domino-and-tromino-tiling/description/?envType=daily-question&amp;amp;envId=2025-05-05" rel="noopener noreferrer"&gt;Domino and Tromino Tiling&lt;/a&gt;, a medium DP question. Figured there was a pattern but couldn't write out the entire generalised formula :(&lt;/li&gt;
&lt;li&gt;TUE - &lt;a href="https://leetcode.com/problems/build-array-from-permutation/description/?envType=daily-question&amp;amp;envId=2025-05-06" rel="noopener noreferrer"&gt;Build Array from Permutation&lt;/a&gt; easy, but interesting to draw on concept of in-place array modification.&lt;/li&gt;
&lt;li&gt;WED - &lt;a href="https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/?envType=daily-question&amp;amp;envId=2025-05-07" rel="noopener noreferrer"&gt;Find Minimum Time to Reach Last Room I&lt;/a&gt;... Djikstra? No. Just use simple DFS if I can't work up to it.&lt;/li&gt;
&lt;li&gt;THU - &lt;a href="https://leetcode.com/problems/find-minimum-time-to-reach-last-room-ii/description/?envType=daily-question&amp;amp;envId=2025-05-07" rel="noopener noreferrer"&gt;Find Minimum Time to Reach Last Room II&lt;/a&gt;, Djikstra again... Should practice DFS tomorrow maybe.&lt;/li&gt;
&lt;li&gt;SAT - &lt;a href="https://leetcode.com/problems/minimum-equal-sum-of-two-arrays-after-replacing-zeros/description/?envType=daily-question&amp;amp;envId=2025-05-09" rel="noopener noreferrer"&gt;Minimum Equal Sum of Two Arrays After Replacing Zeros&lt;/a&gt; medium greedy!&lt;/li&gt;
&lt;li&gt;SUN - did the Easy daily question, then noped the hell out of &lt;a href="https://leetcode.com/problems/largest-number/description/?envType=problem-list-v2&amp;amp;envId=array" rel="noopener noreferrer"&gt;Mathematical Induction proof medium question&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;MON - did the &lt;a href="https://leetcode.com/problems/finding-3-digit-even-numbers/submissions/1631483960/?envType=daily-question&amp;amp;envId=2025-05-09" rel="noopener noreferrer"&gt;Easy daily question&lt;/a&gt;, then optimised it from O(N^3) to O(N^2)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - revised &lt;code&gt;Squash Object&lt;/code&gt;, still have issues with &lt;code&gt;Map Async Limit&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;TUE - * DOM API, State Management, Security, Event Loop, HTTP Error Codes&lt;/li&gt;
&lt;li&gt;WED - &lt;code&gt;Event Emitter&lt;/code&gt; and &lt;code&gt;useDebounce&lt;/code&gt;. This gets boring... where find new questions? 👀&lt;/li&gt;
&lt;li&gt;SAT - QRT Sample JS Coding Quiz had two questions: (1) Write a class that extends an EventEmitter for a search API, and (2) React useState list view page

&lt;ul&gt;
&lt;li&gt;the latter had a tiny gotcha, which is you need to destructure or shallow copy the previous state of articles list, ensuring you're not mutating state directly. React may not re-render if the same array reference is reused, even if its contents are changed via .sort().&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;SAT - Session 2 of QRT Test. Things I learnt:

&lt;ul&gt;
&lt;li&gt;height: 100% doesn't work with display: flex. Need to use &lt;code&gt;align-items: stretch&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;fetch API's response needs to be parsed with &lt;code&gt;response.json()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;CSS with spacebar just means 2 different class names&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;text-decoration&lt;/code&gt; helps with underline&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. System Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MON - design airlines flight staff assignment dashboard&lt;/li&gt;
&lt;li&gt;TUE - * find errors in TodoList / Polling-Cancel code&lt;/li&gt;
&lt;li&gt;WED - Study 2 concepts: &lt;a href="https://web.dev/learn/performance/optimize-resource-loading" rel="noopener noreferrer"&gt;Critical Rendering Path Optimization&lt;/a&gt;, State Hydration and Partial Hydration

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;minification&lt;/code&gt; for quicker load (but that's handled by Webpack usually).&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.astro.build/en/concepts/why-astro/" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; for SSR / hydration&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>behaviour</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Week 13: Renewed Vigor after Holidays</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Sun, 27 Apr 2025 14:55:38 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-13-renewed-vigor-after-holidays-3d99</link>
      <guid>https://forem.com/c6z3h/week-13-renewed-vigor-after-holidays-3d99</guid>
      <description>&lt;p&gt;Two weeks in Australia in both the rural and city areas taught me this: the dream of a beautiful countryside life is not without it's struggles.&lt;/p&gt;

&lt;p&gt;I was lucky to have chanced upon a lady running a wine vineyard, who committed to the Tasmanian countryside during covid to escape from the hustle of Melbourne city life. It seemed it was plenty hard work, even though it looked beautiful for her at the start.&lt;/p&gt;

&lt;p&gt;I also had the chance to meet small town folk - a blacksmith at a Gold Rush era theme park. It wasn't a skill that paid well, but he enjoyed it so much that working was fun for him. A retired operations employee at the Cape Otway Lighthouse emanates a similar glow.&lt;/p&gt;

&lt;p&gt;In the city, people are dreary. Overcrowding causes people to have short fuses. I witnessed a man stop his bicycle at a traffic light, only to have another inattentive cyclist knocking into him lightly from behind. He cursed like there was no tomorrow.&lt;/p&gt;

&lt;p&gt;Yet, there is still little bits of enthusiasm in the city. Like a hotel receptionist that went beyond her job scope and helped us become a "human weighing scale" for our luggage since she used to work for an airlines before. Or an excitable lady doing what she loves, selling books and book-related stuff like crochets and reading socks.&lt;/p&gt;

&lt;p&gt;Life is more of what you make it, than where you live, it feels. With that I find newfound resolve to find my ikigai, or for romanticism's sake, raison d'etre.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;SUN - easy question&lt;/li&gt;
&lt;li&gt;MON - had trouble with hard &lt;code&gt;Sliding Window&lt;/code&gt; question &lt;a href="https://leetcode.com/problems/count-subarrays-with-score-less-than-k/description/?envType=daily-question&amp;amp;envId=2025-04-28" rel="noopener noreferrer"&gt;Count Subarrays With Score Less Than K&lt;/a&gt;. Revise an &lt;a href="https://leetcode.com/problems/contains-duplicate-ii/" rel="noopener noreferrer"&gt;easy SW question&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;TUE - medium SW question &lt;a href="https://leetcode.com/problems/count-subarrays-where-max-element-appears-at-least-k-times/?envType=daily-question&amp;amp;envId=2025-04-29" rel="noopener noreferrer"&gt;Count Subarrays Where Max Element Appears at Least K Times&lt;/a&gt; but still had trouble with it. Couldn't quite get this &lt;a href="https://leetcode.com/problems/count-complete-subarrays-in-an-array/description/?envType=problem-list-v2&amp;amp;envId=sliding-window" rel="noopener noreferrer"&gt;Medium SW question&lt;/a&gt; either. But I did get the hang of the &lt;a href="https://leetcode.com/problems/maximum-average-subarray-i/description/?envType=problem-list-v2&amp;amp;envId=sliding-window" rel="noopener noreferrer"&gt;Easy SW question&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;WED - Easy &lt;a href="https://leetcode.com/problems/find-numbers-with-even-number-of-digits/description/?envType=daily-question&amp;amp;envId=2025-04-30" rel="noopener noreferrer"&gt;Find Numbers with Even Number of Digits&lt;/a&gt;. Did another &lt;code&gt;Math&lt;/code&gt; Easy, but got stumped by Medium DP / Math problem.&lt;/li&gt;
&lt;li&gt;THU - PH rest&lt;/li&gt;
&lt;li&gt;FRI - &lt;a href="https://leetcode.com/problems/push-dominoes/description/?envType=daily-question&amp;amp;envId=2025-05-02" rel="noopener noreferrer"&gt;Push Dominoes&lt;/a&gt;. It's a medium question I couldn't solve in 2022, but could do it now! It isn't super clean, but working from problem to 6 base cases and implementing the if-else sounds like a win!

&lt;ul&gt;
&lt;li&gt;Interesting follow up on prefix sum&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;SAT - Medium Greedy &lt;a href="https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/description/?envType=daily-question&amp;amp;envId=2025-05-03" rel="noopener noreferrer"&gt;Minimum Domino Rotations For Equal Row&lt;/a&gt; but worked it out!&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;SUN - throttle, function.prototype.call, curry&lt;/li&gt;
&lt;li&gt;MON - revised &lt;code&gt;flatten&lt;/code&gt;, &lt;code&gt;promise.all&lt;/code&gt;. Attempt &lt;code&gt;useMediatedState&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;TUE - attempt &lt;code&gt;useWindowSize&lt;/code&gt;. Revised &lt;code&gt;memoize&lt;/code&gt;.

&lt;ul&gt;
&lt;li&gt;useEffect to addEventListener on mount, and removeEventListener on unmount.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;WED - revised &lt;code&gt;promisify&lt;/code&gt;, &lt;code&gt;useDebounce&lt;/code&gt; and &lt;code&gt;Throttle&lt;/code&gt;.&lt;/li&gt;

&lt;li&gt;THU - PH rest&lt;/li&gt;

&lt;li&gt;FRI - COMPLETED &lt;code&gt;useMediatedState&lt;/code&gt; and revised something else.&lt;/li&gt;

&lt;li&gt;SAT - Completed &lt;code&gt;JSON.stringify&lt;/code&gt;, &lt;code&gt;HTML Serialiser&lt;/code&gt; and &lt;code&gt;Middlewares&lt;/code&gt;.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. System Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;SUN - speedrun&lt;/li&gt;
&lt;li&gt;MON - &lt;code&gt;Design a system that allows users to bookmark videos for later viewing.&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;JWT or OAuth token validation on server&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;TUE - &lt;code&gt;Notification Center&lt;/code&gt;. Good, quick run&lt;/li&gt;

&lt;li&gt;WED - &lt;code&gt;displaying real-time stock market data, such as price changes and volume, for a user's watchlist&lt;/code&gt;. Gave ChatGPT better instructions to prompt me instead of giving full answers after my initial response&lt;/li&gt;

&lt;li&gt;THU - PH rest&lt;/li&gt;

&lt;li&gt;FRI - What started from the idea of creating a post to illustrate and compare optimisations from system design optimisations ended in exploring an old project using &lt;code&gt;Next.js&lt;/code&gt; and &lt;code&gt;React&lt;/code&gt;. Hope to complete it today, but maybe it will extend into the weekend.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. JS Theory
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;SUN - HOC, Ref, React 18 (Suspense, Batching)&lt;/li&gt;
&lt;li&gt;MON - React 18 revision (suspense, batching, useTransition), and study &lt;code&gt;useDeferredValue&lt;/code&gt;. Study &lt;code&gt;useLayoutEffect&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;TUE - React 19 &lt;code&gt;useOptimistic&lt;/code&gt;, practice writing custom hook. Also learnt how to upgrade React versions. Key to releasing v19 after v18.2 is to release a v18.3 non-breaking minor version at the same time as v19.0. This version adds &lt;code&gt;console.error&lt;/code&gt; to allow developers to run in local and resolve any issues before fully committing to v19&lt;/li&gt;
&lt;li&gt;WED - revised &lt;code&gt;benefits of React&lt;/code&gt;. Studied &lt;code&gt;benefits of hooks&lt;/code&gt;, and &lt;code&gt;rules of hooks&lt;/code&gt;. Went beyond the basic explanation for the last point!&lt;/li&gt;
&lt;li&gt;THU - &lt;a href="https://www.greatfrontend.com/questions/quiz/what-advantage-is-there-for-using-the-arrow-syntax-for-a-method-in-a-constructor?practice=practice&amp;amp;tab=quiz" rel="noopener noreferrer"&gt;Arrow Syntax VS Traditional Function&lt;/a&gt; Pretty sure I've encountered this before, but in a different form.

&lt;ul&gt;
&lt;li&gt;Arrow Syntax has &lt;code&gt;this&lt;/code&gt; to be fixed at function creation. Traditional Functions allow for this to be modified by &lt;code&gt;bind&lt;/code&gt;, &lt;code&gt;apply&lt;/code&gt;, &lt;code&gt;call&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;FRI - reviewed &lt;code&gt;difference between call and apply&lt;/code&gt;. Studied &lt;a href="https://www.greatfrontend.com/questions/quiz/explain-how-prototypal-inheritance-works?practice=practice&amp;amp;tab=quiz" rel="noopener noreferrer"&gt;Prototype Inheritance&lt;/a&gt;
&lt;/li&gt;

&lt;li&gt;SAT - speedrun through about 10 questions. Reviewed about 5 more. To re-test these 5 high importance questions, and I'll have completed all the high importance questions! 🥳&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Behavioural
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;SUN - rest&lt;/li&gt;
&lt;li&gt;MON - rehearsed 3 questions with GPT, saving some of the 10 free messages for system design practice. It's the first time doing it without referring to my &lt;code&gt;.docx&lt;/code&gt; file for the onsite and it's going well.&lt;/li&gt;
&lt;li&gt;TUE - 3 questions. Speak verbally before typing in.&lt;/li&gt;
&lt;li&gt;WED - 3 questions. Used the 3 stories that I've not used as much. Tomorrow can try speaking into GPT speech-to-audio&lt;/li&gt;
&lt;li&gt;THU - PH rest&lt;/li&gt;
&lt;li&gt;FRI - tried speech-to-text, and turns out I use a lot of filler words and / or sound uncertain. Need more practice!&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Week 10: Pre-Holiday</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Mon, 07 Apr 2025 03:15:30 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-10-pre-holiday-31j0</link>
      <guid>https://forem.com/c6z3h/week-10-pre-holiday-31j0</guid>
      <description>&lt;p&gt;It's a pretty rewarding week, learning various stuff and even applying some concepts to my personal website. I'm off for holidays next week though, looking forward!&lt;/p&gt;

&lt;p&gt;But for now, here are the topics again:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Leetcode&lt;/li&gt;
&lt;li&gt;JS Coding&lt;/li&gt;
&lt;li&gt;System Design / JS Theory&lt;/li&gt;
&lt;li&gt;Behavioural&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Mon] &lt;a href="https://leetcode.com/problems/partition-equal-subset-sum/?envType=daily-question&amp;amp;envId=2025-04-07" rel="noopener noreferrer"&gt;Partition Equal Subset Sum&lt;/a&gt; &lt;code&gt;Dynamic Programming&lt;/code&gt;, seemingly a 0/1 knapsack problem. DP is difficult still :x&lt;/li&gt;
&lt;li&gt;[Tue] Easy question, so I did another Medium. Good day!&lt;/li&gt;
&lt;li&gt;[Wed] Done &lt;a href="https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/?envType=daily-question&amp;amp;envId=2025-04-09" rel="noopener noreferrer"&gt;Minimum Operations to Make Array Values Equal to K (E)&lt;/a&gt;. Attempted &lt;a href="https://leetcode.com/problems/smallest-range-ii/description/" rel="noopener noreferrer"&gt;Smallest Range II (M)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;[Thu] Attempted &lt;a href="https://leetcode.com/problems/count-the-number-of-powerful-integers/editorial/?envType=daily-question&amp;amp;envId=2025-04-10" rel="noopener noreferrer"&gt;Count the Number of Powerful Integers
(H)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;[Fri] Easy question&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Mon] Did &lt;code&gt;useInputControl&lt;/code&gt; (M) and &lt;code&gt;useClickAnywhere&lt;/code&gt; (E)! Re-attempted &lt;code&gt;Map Async Limit&lt;/code&gt; successfully!&lt;/li&gt;
&lt;li&gt;[Tue] Attempted &lt;code&gt;Middlewares&lt;/code&gt;, &lt;code&gt;Cycles&lt;/code&gt;, and &lt;code&gt;useCounter II&lt;/code&gt;!&lt;/li&gt;
&lt;li&gt;[Wed] Did &lt;code&gt;useCycle&lt;/code&gt;, &lt;code&gt;useSet&lt;/code&gt; and &lt;code&gt;useTimeout&lt;/code&gt;!&lt;/li&gt;
&lt;li&gt;[Thu] &lt;code&gt;Min By (E)&lt;/code&gt; and &lt;code&gt;Count By (M)&lt;/code&gt;! Attempted &lt;code&gt;getElementsByClassName (M)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[Fri] work problems... Using a ref to pass between data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. System Design / JS Theory
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Mon] Try quick-fire 10 questions.

&lt;ul&gt;
&lt;li&gt;Revised 6: &lt;code&gt;== vs ===&lt;/code&gt;, &lt;code&gt;event delegation&lt;/code&gt;, &lt;code&gt;Virtual DOM&lt;/code&gt;, &lt;code&gt;cookies, localStorage &amp;amp; sessionStorage&lt;/code&gt;, &lt;code&gt;hoisting&lt;/code&gt;, and &lt;code&gt;&amp;lt;script / async / defer&amp;gt;&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;cookies&lt;/code&gt; are sent on every request, first sent by server&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Studied 4: &lt;code&gt;func.bind&lt;/code&gt;, &lt;code&gt;event capturing&lt;/code&gt;, &lt;code&gt;What's JSX&lt;/code&gt;, &lt;code&gt;error handling for async functions&lt;/code&gt;
&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;[Tue] Quick-fire optimisations! UX: Lazy Loading, Skeleton Loading, Silent Loading, Image fixed width and height for CLS, Error Prompts, Virtualised Lists, Caching (Redis / LocalStorage). Accessibility: &lt;code&gt;Dark Mode&lt;/code&gt;, Aria Labels / &lt;code&gt;Lang for screen reader&lt;/code&gt;, Button navigation and execution. Security: disable CORS, &lt;code&gt;sanitize inputs (React default)&lt;/code&gt;. SEO: &lt;code&gt;meta tag with description&lt;/code&gt;.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Content-Security-Policy&lt;/code&gt; HTTP Header to define trusted source of scripts and resources, reducing change of XSS attacks. &lt;a href="https://griddynamics.medium.com/front-end-security-best-practices-8c47d23caf62" rel="noopener noreferrer"&gt;A good resource&lt;/a&gt;. Example: &lt;code&gt;Content-Security-Policy: script-src ‘self’&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;[Wed] Yesterday's security article and a bit on keyloggers, and some &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#alternative-using-a-double-submit-cookie-pattern" rel="noopener noreferrer"&gt;CSRF best practices by OWASP&lt;/a&gt;, basically a per-request token sent in the HTTPS headers.&lt;/li&gt;

&lt;li&gt;[Thu] -rest-&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Behavioural
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Mon] 4 questions with back-and-forth answered today! Feeling confident&lt;/li&gt;
&lt;li&gt;[Tue] 5 questions today! Feels great, and I find I have more stories as the questions come along. But perhaps I should constrain myself to the 7 - 10 stories I have and apply them to different questions. Otherwise I might not be able to follow STAR format&lt;/li&gt;
&lt;li&gt;[Wed] 4 questions!&lt;/li&gt;
&lt;li&gt;[Thu] -rest-&lt;/li&gt;
&lt;li&gt;[Fri] -rest-&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>learning</category>
    </item>
    <item>
      <title>Week 9: Back to the Grind</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Tue, 01 Apr 2025 16:01:09 +0000</pubDate>
      <link>https://forem.com/c6z3h/week-9-back-to-the-grind-58ld</link>
      <guid>https://forem.com/c6z3h/week-9-back-to-the-grind-58ld</guid>
      <description>&lt;p&gt;Wow. It's already the 9th week since I resolved to study and improve my frontend skills. We've come quite far since Chinese New Year. The previous posts were all pretty haphazard, so here's hoping that it'll be more organised from here on out.&lt;/p&gt;

&lt;p&gt;Each post will be a summary of 4 study areas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Leetcode&lt;/li&gt;
&lt;li&gt;JS Coding&lt;/li&gt;
&lt;li&gt;System Design / JS Theory&lt;/li&gt;
&lt;li&gt;Behavioural&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Leetcode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Tue] &lt;a href="https://leetcode.com/problems/solving-questions-with-brainpower/?envType=daily-question&amp;amp;envId=2025-04-01" rel="noopener noreferrer"&gt;Solving Questions with Brainpower&lt;/a&gt;. &lt;code&gt;Dynamic Programming&lt;/code&gt; skills is rusty. Revised &lt;code&gt;Fibonacci Sequence (Easy)&lt;/code&gt; and &lt;code&gt;Jump Game (Medium)&lt;/code&gt; for DP.&lt;/li&gt;
&lt;li&gt;[Wed] &lt;a href="https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-i/editorial/?envType=daily-question&amp;amp;envId=2025-04-02" rel="noopener noreferrer"&gt;Maximum Value of an Ordered Triplet I
&lt;/a&gt;. &lt;code&gt;Greedy&lt;/code&gt; and &lt;code&gt;Prefix Sum&lt;/code&gt; eludes me. But based on algomonster it seems rare, so I shan't study too hard.&lt;/li&gt;
&lt;li&gt;[Thu] &lt;a href="https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-ii/description/?envType=daily-question&amp;amp;envId=2025-04-03" rel="noopener noreferrer"&gt;Maximum Value of an Ordered Triplet II&lt;/a&gt; solved yesterday, so I tried a &lt;a href="https://leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-i/solutions/5788363/python3-trie-dp/" rel="noopener noreferrer"&gt;random Medium question&lt;/a&gt; Thought to solve with &lt;code&gt;Trie&lt;/code&gt; and &lt;code&gt;DP&lt;/code&gt;, but couldn't combine. Revised &lt;code&gt;Trie&lt;/code&gt; concept with &lt;a href="https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/" rel="noopener noreferrer"&gt;Count Prefix and Suffix Pairs I&lt;/a&gt;. Can try to optimise for II.&lt;/li&gt;
&lt;li&gt;[Fri] &lt;a href="https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/submissions/1596306339/?envType=daily-question&amp;amp;envId=2025-04-04" rel="noopener noreferrer"&gt;Lowest Common Ancestor of Deepest Leaves&lt;/a&gt; &lt;code&gt;DFS&lt;/code&gt;, &lt;code&gt;Binary Tree&lt;/code&gt; question. Not optimal because couldn't code out &lt;code&gt;post-order traversal&lt;/code&gt;, but got it!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. JS Coding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Tue] GFE new hooks questions &lt;code&gt;useBoolean&lt;/code&gt; and &lt;code&gt;useArray&lt;/code&gt;. EZ&lt;/li&gt;
&lt;li&gt;[Wed] 2 Medium -- Tried &lt;code&gt;useQuery&lt;/code&gt; medium question, revised &lt;code&gt;Promise.all&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[Thu] &lt;code&gt;useMediaQuery&lt;/code&gt; (new) and &lt;code&gt;useDebounce&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[Fri] Revised, re-studied &lt;code&gt;curry&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. System Design / JS Theory
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Tue] &lt;a href="https://www.youtube.com/watch?v=Tu-hZ6lqNtY" rel="noopener noreferrer"&gt;Design Netflix&lt;/a&gt;. This was rather interesting, as it resembled my daily work. But to draft all the flow charts in 45 minutes is crazy, guess I'll stick to greatfrontend's format.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;WebP&lt;/code&gt; -- this is a format of image that is well supported on most browsers, takes up less space than PNGs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;HTTP2&lt;/code&gt; -- seems multiplexing where concurrent requests can be sent is the main improvement &lt;a href="https://www.imperva.com/learn/performance/http2/" rel="noopener noreferrer"&gt;(see here)&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;[Wed] &lt;a href="https://www.youtube.com/watch?v=lO6GyCvbDm8&amp;amp;list=PLI9W87-Dqn7j_x6QtR6sUjycJR7nQLBqT&amp;amp;index=7" rel="noopener noreferrer"&gt;Design a Poll Widget&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Offline Retry / &lt;code&gt;Exponential Backoff&lt;/code&gt; - helpful for a highly-loaded server to reduce &lt;code&gt;429 Too Many Requests&lt;/code&gt; when it has transient downtime.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rems&lt;/code&gt; instead of pixels -- root EMs are relative to root font size, so will look correct on different devices. Pixels are fixed width.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;[Thu] Studied &lt;a href="https://www.patterns.dev/" rel="noopener noreferrer"&gt;design patterns&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Singleton&lt;/code&gt; seems useful if you need a global instance. Perhaps a common tracking class with default values so save memory when recreate&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Proxy&lt;/code&gt; doesn't seem useful if you can directly perform validations in the object.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Dark Mode&lt;/code&gt; implemented for my &lt;a href="https://c6z3h.github.io" rel="noopener noreferrer"&gt;website!&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;[Fri] &lt;a href="https://www.youtube.com/watch?v=u6jhTo13_No&amp;amp;list=PLI9W87-Dqn7j_x6QtR6sUjycJR7nQLBqT&amp;amp;index=6" rel="noopener noreferrer"&gt;Data Table component&lt;/a&gt; but many things feel abstract. I might have to implement them to get a hang of it. Perhaps Monday's System Design will be considering work product.&lt;/li&gt;

&lt;li&gt;[Sun] &lt;a href="//pagespeed.web.dev"&gt;Chrome LightHouse&lt;/a&gt; experiments on &lt;a href="https://c6z3h.github.io/" rel="noopener noreferrer"&gt;my personal site!&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SEO&lt;/code&gt;: Added meta description to headers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Accessibility&lt;/code&gt;: HTML element does not have a language attribute&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Behavioural
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Tue] It seems my resentment for the current workplace is strong, and ChatGPT suggests reframing it as a lesson learnt for the future, rather than focusing on emotions.&lt;/li&gt;
&lt;li&gt;[Wed] Read a few quick guides and practiced 3 more questions. Looks good today!&lt;/li&gt;
&lt;li&gt;[Thu] Did 1 question back-and-forth. Felt more realistic&lt;/li&gt;
&lt;li&gt;[Fri] 30 minutes back-and-forth, 2 signpost questions. GPT has limit of 10 messages in 4 hours, but that's just nice for this.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>career</category>
      <category>interview</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Frontend Fundamentals 16: System Design Intensive</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Sun, 16 Feb 2025 06:14:43 +0000</pubDate>
      <link>https://forem.com/c6z3h/frontend-fundamentals-16-system-design-intensive-3if4</link>
      <guid>https://forem.com/c6z3h/frontend-fundamentals-16-system-design-intensive-3if4</guid>
      <description>&lt;p&gt;Previous post in the series has been rather cluttered and maybe I should dedicate a single post to all things related to this topic.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Design JIRA Sprint Board
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Requirements
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;create, edit, delete tasks&lt;/li&gt;
&lt;li&gt;update task progress&lt;/li&gt;
&lt;li&gt;view dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Architecture
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;VIEW: Editor + Dashboard&lt;/li&gt;
&lt;li&gt;CONTROLLER: Cache + Business Logic&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Data Model / Interface
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Edit task UI (form for filling description etc, button for updating task progress)&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;input: { description?: string; daysRequired?: number; ... }&lt;/li&gt;
&lt;li&gt;output: { status?: "SUCCESS" | "FAIL" | "PENDING" }&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Dashboard Summary&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;input: filters = { user: string; startDate: string; endDate: string }&lt;/li&gt;
&lt;li&gt;output: columns = { daysRequired: number; title: string ; ... }&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Optimisation
&lt;/h4&gt;

&lt;p&gt;Error Handling / UIUX&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cache for offline view.&lt;/li&gt;
&lt;li&gt;Hooks to display offline banner if user internet is disconnected.&lt;/li&gt;
&lt;li&gt;Since it's not urgent like a stocks trading app, update on refresh page is good enough.&lt;/li&gt;
&lt;li&gt;To handle concurrent updates (rare but possible), Keep a history log of updates (i.e each request needs to be sent with the timestamp), or do a check with BE data to see if user's previousData and nextData is correct, if somehow the previousData is outdated because someone else already changed it, throw user a popup error to say it has been modified and needs change.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Accessibility&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No need for mobile-view since we won't expect people to update their tasks on their phone... coding tasks done on PC so it should be easier to update on PC. This simplifies code maintainability, since no need for media-queries. Perhaps if screen size detected is in the range of tablets to phones, then show a blank page saying it isn't supported.&lt;/li&gt;
&lt;li&gt;Filter support. Different stakeholders need to see different data, and having this to allow them to see only relevant columns is important.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Security&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validate user credentials on login, and send them via each request. This is so that outsiders cannot access the data privy to the company using this dashboard.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  🚨 Review &lt;a href="https://www.youtube.com/watch?v=1tsAdkqunqQ" rel="noopener noreferrer"&gt;(source)&lt;/a&gt;:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Consider images&lt;/li&gt;
&lt;li&gt;What network protocol is best?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Consider studying from FrontendLead: &lt;a href="https://frontendlead.com/" rel="noopener noreferrer"&gt;https://frontendlead.com/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Frontend Fundamentals 11, 12, 13, 14, 15 (Wtf is `this`?)</title>
      <dc:creator>ZhiHong Chua</dc:creator>
      <pubDate>Mon, 10 Feb 2025 05:01:39 +0000</pubDate>
      <link>https://forem.com/c6z3h/frontend-fundamentals-11-wtf-is-this-33a5</link>
      <guid>https://forem.com/c6z3h/frontend-fundamentals-11-wtf-is-this-33a5</guid>
      <description>&lt;h2&gt;
  
  
  1. Understanding &lt;code&gt;this&lt;/code&gt;, &lt;code&gt;apply&lt;/code&gt;, &lt;code&gt;call&lt;/code&gt;, and &lt;code&gt;bind&lt;/code&gt; with ChatGPT.
&lt;/h2&gt;

&lt;p&gt;So I told GPT I was unsure of these concepts and made it test me with some questions then evaluate my answers. Here are my takeaways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;call&lt;/code&gt; uses comma-separated arguments, and &lt;code&gt;apply&lt;/code&gt; uses array of arguments&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; refers to (1) object itself in object methods, (2) newly created instance in constructor methods, and (3) global object (window) in global function non-strict mode&lt;/li&gt;
&lt;li&gt;arrow functions inherit &lt;code&gt;this&lt;/code&gt; from lexical context, while traditional functions inherit &lt;code&gt;this&lt;/code&gt; from where it is called&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bind()&lt;/code&gt; helps us attach a context to a function that will be used later&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More questioning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;global&lt;/code&gt; mode is not preferred these days, but may be encountered when dealing with legacy code
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Regular function in setTimeout: `this` is not bound to `user`.&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Regular timer:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Arrow function in setTimeout: inherits `this` from greet.&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Arrow timer:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&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="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// Expected Output after 1 second:&lt;/span&gt;
&lt;span class="c1"&gt;// "Regular timer:" may log undefined (or error in strict mode).&lt;/span&gt;
&lt;span class="c1"&gt;// "Arrow timer: Bob" logs correctly.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Sample 3 JS &lt;code&gt;this&lt;/code&gt; questions to solidify understanding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🚨 &lt;a href="https://leetcode.com/problems/promise-time-limit/?envType=study-plan-v2&amp;amp;envId=30-days-of-javascript" rel="noopener noreferrer"&gt;Promise Time Limit&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://leetcode.com/problems/execute-asynchronous-functions-in-parallel/?envType=study-plan-v2&amp;amp;envId=30-days-of-javascript" rel="noopener noreferrer"&gt;Promise.all&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Open-ended Discussions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;STAR framework&lt;/li&gt;
&lt;li&gt;7 to 10 good stories&lt;/li&gt;
&lt;li&gt;interest, enthusiasm&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.greatfrontend.com/behavioral-interview-playbook/introduction" rel="noopener noreferrer"&gt;Things people are interested in:&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will this person be a superstar, driven teammate? e.g. communicates well, resourceful and independent in solving problems, able to manage stakeholders, proactive and works hard in enacting new initiatives to drive the team forward.&lt;/li&gt;
&lt;li&gt;Will this person be easy to manage? e.g. takes feedback well, likable, sociable and does not give you problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Answer 16 Common Questions on ChatGPT and Evaluate Answers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🚨 + how does this learning point lead to future improvements&lt;/li&gt;
&lt;li&gt;🚨 anticipate follow up questions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Prepare 7 to 10 Stories
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Credit Card Flip Animation&lt;/li&gt;
&lt;li&gt;&lt;del&gt;QA that likes to test extreme edge case&lt;/del&gt;&lt;/li&gt;
&lt;li&gt;Reduce bundle size 7% via CV&lt;/li&gt;
&lt;li&gt;&lt;del&gt;Reducing possible investment states with PM&lt;/del&gt;&lt;/li&gt;
&lt;li&gt;Guiding a junior engineer / writing es lint&lt;/li&gt;
&lt;li&gt;RichText component cross-market&lt;/li&gt;
&lt;li&gt;Optimising homepage load times
(8. Cybersecurity project)
(9. Gitlab CICD for website crash)
(10. Supporting BE - reduce data load by 200%, debugging shared system)
(11. Script to reduce transify bugs)&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Frontend Fundamentals 12
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1, 2, and 3. JS Questions
&lt;/h2&gt;

&lt;p&gt;Revisiting some old problems like&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Debounce ✅&lt;/li&gt;
&lt;li&gt;Function.prototype.call ✅&lt;/li&gt;
&lt;li&gt;Curry ✅&lt;/li&gt;
&lt;li&gt;Promisify ✅
🚨 Need to work on more in-depth understanding&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  4. System Design 1: Global Payments Dashboard
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Websockets provide low latency&lt;/li&gt;
&lt;li&gt;Caching strategies in high-update environment (Cache for non-laggy UI, fetch in background for clean UX)&lt;/li&gt;
&lt;li&gt;Handling race conditions in high-update environment (Optimistic update, for quicker UI response. Version and timestamp, to ensure updates are applied in correct order)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. System Design 2: Internal Corporate Messaging Platform
&lt;/h2&gt;

&lt;p&gt;🚨 What do big companies use?&lt;/p&gt;

&lt;h1&gt;
  
  
  Frontend Fundamentals 13: Taking a step back
&lt;/h1&gt;

&lt;p&gt;Taking a step back, I realise I might have been too focused on practice questions. A holistic approach to understanding such as trying questions specific to my existing knowledge and required tasks may be helpful. ChatGPT created a list of 9 questions for this, and my takeaways were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;virtualised lists keeps the Virtual DOM clean by hiding items not rendered, and removing items scrolled-past.&lt;/li&gt;
&lt;li&gt;BFF, Apollo Client / GraphQL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And then I got another 5 questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSP and CSRF token-based protection&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  FF 14: Revision Time
&lt;/h1&gt;

&lt;p&gt;This time a focus on 2 random JS questions from the internet for practice on knowledge application, and revision on 3 alarm bell items on my past notes might be helpful.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Flatten Array ✅
&lt;/h2&gt;

&lt;h2&gt;
  
  
  2. GFE Medium
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;First Bad Version&lt;/li&gt;
&lt;li&gt;Memoize (with resolver function)&lt;/li&gt;
&lt;li&gt;Implement Queue using Stack (🚨 I wrote the same code but it don't return)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sum() curry&lt;/code&gt; (🚨 &lt;code&gt;func.valueOf()&lt;/code&gt; is unstable)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. BFF / Apollo Client / GraphQL
&lt;/h2&gt;

&lt;p&gt;BFF handled by FE team allows them to customize response for each device type (eg. Less data required for mobile). This is also something GraphQL provides, sort of as intermediate backend. Apollo Client helps with that. I think no need to study this since it's a framework that can be learnt when required.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Big Tech's Approach to High Update Messaging
&lt;/h2&gt;

&lt;p&gt;Seems that Telegram use MTProto (websocket), Whatsapp use MQTT (pub/sub). But none of it relies on the basic transport protocol. They seem to stack a lot more to achieve their business needs.&lt;/p&gt;

&lt;p&gt;Websocket provides low latency but potentially less safe, unless you add things on top of it. Pub/Sub is uni-directional and may need deconflicting in an actual app...&lt;/p&gt;

&lt;h2&gt;
  
  
  5. CSP / CSRF token protection
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP has a guide on Synchronizer Token Pattern&lt;/a&gt;, which require a per-session valid token for every network request so we can ensure token used is from the actual user, not forged.&lt;/p&gt;

&lt;h1&gt;
  
  
  FF15 and later: (a) 2 JS questions, and (b) 2 SD/B questions, per day
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. JS Questions (Medium)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;array.prototype.flat()&lt;/li&gt;
&lt;li&gt;decode message&lt;/li&gt;
&lt;li&gt;string.trim()&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. React (Hooks) Questions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;usePrevious&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bigfrontend.dev/react/usetimeout" rel="noopener noreferrer"&gt;useTimeout&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🚨 Need to work on my hooks debugging skills&lt;/p&gt;

&lt;h2&gt;
  
  
  3. CSS Questions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://bigfrontend.dev/css/center-an-element-vertically" rel="noopener noreferrer"&gt;center a div&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bigfrontend.dev/css/truncate-text-with-ellipsis-in-one-line" rel="noopener noreferrer"&gt;truncate one-line text with ellipsis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://bigfrontend.dev/css/two-column-layout" rel="noopener noreferrer"&gt;two column layout&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🚨 Need to work on my CSS debugging skills&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
