<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Njange on Medium]]></title>
        <description><![CDATA[Stories by Njange on Medium]]></description>
        <link>https://medium.com/@njange?source=rss-ce8051390caf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vonOreeQSz4wEP5N</url>
            <title>Stories by Njange on Medium</title>
            <link>https://medium.com/@njange?source=rss-ce8051390caf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:18:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@njange/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Solving LeetCode 2044: Count Number of Maximum Bitwise-OR Subsets]]></title>
            <link>https://njange.medium.com/solving-leetcode-2044-count-number-of-maximum-bitwise-or-subsets-8a69dd0287bb?source=rss-ce8051390caf------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a69dd0287bb</guid>
            <dc:creator><![CDATA[Njange]]></dc:creator>
            <pubDate>Mon, 28 Jul 2025 08:30:11 GMT</pubDate>
            <atom:updated>2025-07-28T08:30:11.690Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Author: James</strong><br> <strong>Date: July 28, 2025</strong></p><p>LeetCode problems are not just about writing code. Often, they’re about learning to <strong>think differently</strong>. One such elegant problem is <strong>Leetcode 2044</strong>: <em>Count Number of Maximum Bitwise-OR Subsets</em>.</p><p>Let’s walk through my thought process and the logic behind my Python solution, with the aim of making the solution intuitive and inspiring for your own problem-solving journey.</p><h3>Problem Statement</h3><blockquote><em>Given an integer array </em><em>nums, return the number of non-empty subsets whose bitwise OR value is the </em><strong><em>maximum possible</em></strong><em> among all subsets of </em><em>nums.</em></blockquote><h3>Understanding the Requirements</h3><p>At a glance, it sounds like a brute-force nightmare — examining every subset and calculating their bitwise ORs?</p><p>But here’s the good news:</p><ul><li>nums.length is <strong>at most 16</strong>. So, total subsets = 2^n = 65,536 max.</li><li>We’re <strong>allowed</strong> to explore all subsets recursively.</li></ul><p>So the challenge is not in managing scale, but in making <strong>recursive thinking</strong> work for us.</p><h3>Step-by-Step Strategy</h3><h3>Step 1: What’s the Target?</h3><p>We first compute the <strong>maximum possible OR value</strong> across all combinations.</p><p>We do this with:</p><pre>python3</pre><pre>or_sum |= x</pre><p>for each x in nums.</p><p>This gives us a target OR value to compare against when scanning subsets.</p><h3>Step 2: Generate All Subsets</h3><p>Next, we <strong>recursively</strong> explore all subsets using a depth-first approach.</p><p>At each index, we make two choices:</p><ol><li><strong>Exclude</strong> the current element.</li><li><strong>Include</strong> the current element (and update OR value).</li></ol><h3>Step 3: Count Valid Subsets</h3><p>Whenever we reach the end of a path (i.e., formed a complete subset), we check:</p><ul><li>Does the OR value match our or_sum?</li><li>If yes, increment a count.</li></ul><h3>✅ Python Solution</h3><pre>python3</pre><pre>class Solution:<br>    def countMaxOrSubsets(self, nums: List[int]) -&gt; int:<br>        N = len(nums)<br>        or_sum = 0<br>        for x in nums:<br>            or_sum |= x  # Compute max possible OR</pre><pre>        count = 0</pre><pre>        def calc(index, current):<br>            if index == N:<br>                if current == or_sum:<br>                    nonlocal count<br>                    count += 1<br>                return</pre><pre>            # Don&#39;t include current number<br>            calc(index + 1, current)<br>            # Include current number<br>            calc(index + 1, current | nums[index])</pre><pre>        calc(0, 0)<br>        return count</pre><h3>🤯 Why This Works</h3><ul><li><strong>Bitwise OR is monotonic</strong>: adding elements can only increase or maintain the OR.</li><li>We <strong>explore every combination</strong> (via recursion), but only <strong>count</strong> the ones that match the max OR.</li><li>Recursive DFS + Bitwise logic = powerful combo.</li></ul><h3>Complexity</h3><ul><li><strong>Time</strong>: O(2ⁿ), where n = number of elements in nums</li><li><strong>Space</strong>: O(n) recursion stack</li></ul><p>Totally acceptable given n ≤ 16.</p><h3>Things to Learn from This</h3><ul><li>When the input size is small (≤ 16), brute-force with optimization becomes viable.</li><li>Recursion is not scary — it’s a <em>natural</em> way to model choices and combinations.</li><li>Bitwise operations can simplify problems when combined with subset generation.</li></ul><h3>Can This Be Improved?</h3><p>We could consider:</p><ul><li><strong>Memoization</strong>: Avoid recomputing states (though not strictly necessary here).</li><li><strong>Bitmasking</strong>: Replace recursion with a loop using bitmasks for practice.</li></ul><p>But overall, the current solution is clean, readable, and efficient for the problem constraints.</p><h3>Tags</h3><p>#Leetcode #Bitwise #Recursion #Python #Backtracking #DFS #Subsets #Algorithm</p><h3>Final Thoughts</h3><p>If you’ve been intimidated by recursion or bitwise operations, this problem is a great stepping stone. It’s proof that <strong>elegance</strong> lies not in complexity but in clarity of thought.</p><p>Want more breakdowns like this? Drop a comment, or connect with me. Let’s talk tech, logic, and algorithms.</p><p>✌️<br> <strong>James</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a69dd0287bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Kenya’s Tech Talent Pipeline Is Broken]]></title>
            <link>https://njange.medium.com/why-kenyas-tech-talent-pipeline-is-broken-c0dd1ae66dbf?source=rss-ce8051390caf------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0dd1ae66dbf</guid>
            <dc:creator><![CDATA[Njange]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 10:38:04 GMT</pubDate>
            <atom:updated>2025-07-27T12:17:45.802Z</atom:updated>
            <content:encoded><![CDATA[<p>By James N.</p><p>In buzzing coworking spaces scattered across Nairobi’s tech belt, young people are building things. Bootcamps are in session. Laptops glow. Whiteboards fill with arrows and API calls. At the heart of it all is an intoxicating promise: that by learning to code, one can escape unemployment, enter the digital economy, and become a global problem-solver. It’s a beautiful story. But beneath the hullabaloo of all this frenetic change, a deeper question begs: Are we really creating builders or just building consumers of AI tools?</p><p>Kenya’s youth unemployment crisis is as silent as it is loud. Recent estimates by the Federation of Kenya Employers project that nearly 67% of Kenya’s youth, between the ages of 15 and 34, are still unemployed. That’s not a figure it’s a warning to a generation. Each year, over 800,000 young adults enter the workforce. Formal employment generation reaches barely a fraction of that. The vast majority end up in the informal economy. The bootcamp wave is at least partly here to serve as a gap filler. It offers a robust alternative: rapid upskilling on tech tools with a potential shot at local or remote tech work.</p><p>The truth is, many bootcamps do live up to their hype on paper. Others tout 75% placement. They learn to build full-stack web applications, cloud-deploy, and manage Git repositories. They graduate and earn their badges. And yet, so many of them are soon faced with the actual world a world where employers don’t want to know about tools but depth, design thinking, and system-level thinking. The world they face is unfamiliar, and often unforgiving.</p><p>Besides, the alumni of these bootcamps are stepping into an AI-led tech world. In Kenya, AI platforms like ChatGPT are not just a trend so popular, they’re a phenomenon. Over 42% of Kenyan internet users reportedly used ChatGPT in a specific month, almost double the worldwide average. Kenya ranks in the top 3 countries globally based on ChatGPT usage, second only to the U.S. and India. AI tools are now a part of the overall scheme of how young programmers learn, debug, and even write entire programs. That’s not necessarily bad it’s a manifestation of quickness and cleverness. But it does quietly ask the question: are we actually educating people to understand systems they construct, or just how to prompt a chatbot to assemble them?</p><p>When ChatGPT can scaffold your backend, code your models, code your tests, and explain your stack, temptation to sidestep the thinking is tempting. And when correctness is a function of output shipping something, anything depth is the casualty. Now you can ship a web app in a matter of days without having to understand a single algorithm, system design pattern, or security threat. As a result, we’re seeing a rise in what might be called “AI-assisted developers” not builders in the traditional sense, but rather assemblers of code, guided by prompts, tutorials, and autocomplete.</p><p>This isn’t to embarrass anyone. Really, it’s a testament to what can be done with persistence and the right set of tools. But it does create a false illusion of expertise. Knowing how to operate ChatGPT is not necessarily knowing how software operates. Knowing how to call an API is not necessarily knowing how to design one that scales, fails well, and honors user data.</p><p>Meanwhile, the labor market remains unyielding. Local companies still need mid- and senior-level engineers who are reluctant or cannot afford to take on juniors requiring training. The startups who would have employed bootcamp talent are themselves struggling with funding gaps or outsourcing development. What one finds is an abundance of talent at the lower end of the pipeline and a shortage of mentoring and formal apprenticeships. Other graduates move into freelancing, where international competition prevails and income is sporadic. Others move into tech-related lines marketing, training, online media or leave the field entirely.</p><p>So we must confront an unpleasant truth. Kenya is producing more coders than ever before. But coding is different from building. Bootcamps teach people how to use tools. But tools without knowledge develop superficial makers. They create copies of individuals instead of manufacturing innovations. Kenya does not need Twitter or Airbnb replicas. It needs original minds. Systems thinkers. Moral technologists. Innovators who can conjure something up out of thin air and craft it with love and care.</p><p>To achieve this, we must go beyond quick skilling and start valuing depth. Bootcamps must evolve. They must focus on teaching less about structures and more about fundamentals. More regarding questioning what should actually be built in the first place, and less on how to finish a project. Project-based learning must include failure, confusion, and ethics. Mentorship must be treated as central infrastructure, and not a voluntary add-on. And we must enable pathways for young people to develop not just progress.</p><p>To the graduates in this room: don’t settle for superficial mastery. Break things. Read code you don’t comprehend. Pose questions that computers can’t. Identify the philosophy of software, not its syntax. Study not just how to build but why.</p><p>Ultimately, it is a fundamental but pressing question: Are we teaching makers or creating a generation of consumers of shortcuts? Because in this age of such vast technological potential, the future won’t be for the folk who can only throw the quickest. It will be for those who comprehend the systems deeply enough that they can shape them.</p><p>Let’s choose humorously to make. Deliberately. With attention. And with inquiry.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0dd1ae66dbf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving LeetCode 3202: Maximum Length of a Subsequence With Limited Difference]]></title>
            <link>https://njange.medium.com/solving-leetcode-3202-maximum-length-of-a-subsequence-with-limited-difference-3f86105f3366?source=rss-ce8051390caf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f86105f3366</guid>
            <category><![CDATA[leetcode-medium]]></category>
            <category><![CDATA[leetcode-solution]]></category>
            <category><![CDATA[leetcode]]></category>
            <dc:creator><![CDATA[Njange]]></dc:creator>
            <pubDate>Thu, 17 Jul 2025 08:12:10 GMT</pubDate>
            <atom:updated>2025-07-17T08:12:10.696Z</atom:updated>
            <content:encoded><![CDATA[<p>LeetCode problem <strong>3202</strong>, titled <em>“Maximum Length of a Subsequence With Limited Difference,”</em> presents a fun and tricky dynamic programming challenge that tests your understanding of subsequences, difference constraints, and efficient memoization.</p><p>In this article, we’ll:</p><ul><li>Break down what the problem wants</li><li>Understand a brute-force approach</li><li>Optimize it using dynamic programming with memoization</li><li>And finally, walk through the complete code solution</li></ul><h3>The Problem Statement</h3><p>You’re given an array nums and an integer k. Your goal is to find the <strong>maximum length</strong> of a <strong>subsequence</strong> of nums such that <strong>at most </strong><strong>k adjacent differences are greater than 1</strong>.</p><h3>Key Insights</h3><ul><li>You’re working with a <strong>subsequence</strong>, not a subarray — so elements don’t have to be contiguous.</li><li>You can tolerate <strong>at most </strong><strong>k jumps</strong> where the difference between two consecutive elements in the subsequence is greater than 1.</li><li>The challenge is to pick such a subsequence that’s as <strong>long as possible</strong>.</li></ul><h3>Brute Force Approach</h3><p>One way to solve this is by generating <strong>all subsequences</strong> and counting how many adjacent differences exceed 1. But that’s computationally expensive — for n = 1000, you&#39;d have to explore 2^1000 possibilities. Totally infeasible.</p><p>So we need to use <strong>Dynamic Programming</strong>.</p><h3>Dynamic Programming Idea</h3><p>We define a recursive function:</p><pre>python3</pre><pre>dp(index, prev_index, used_diff)</pre><ul><li>index: the current position in nums</li><li>prev_index: the index of the last selected element (or -1 if none yet)</li><li>used_diff: how many times we’ve already used a “jump” where difference &gt; 1</li></ul><p>We can make two choices at each step:</p><ol><li><strong>Skip </strong><strong>nums[index]</strong> and move on.</li><li><strong>Include </strong><strong>nums[index]</strong> if:</li></ol><ul><li>This is the first element, or</li><li>The difference with the last selected element is &lt;= 1, or</li><li>The difference is &gt; 1 but we still have remaining k differences allowed</li></ul><p>We then return the maximum length from both options.</p><p>To make this efficient, we <strong>memoize</strong> our DP function using functools.lru_cache.</p><h3>Python Code</h3><p>Here’s the complete Python solution:</p><pre>python3</pre><pre>from typing import List<br>from functools import lru_cache</pre><pre>class Solution:<br>    def maximumLength(self, nums: List[int], k: int) -&gt; int:<br>        n = len(nums)</pre><pre>        @lru_cache(None)<br>        def dp(i: int, prev_idx: int, used_diff: int) -&gt; int:<br>            if i == n:<br>                return 0</pre><pre>            # Option 1: skip current element<br>            res = dp(i + 1, prev_idx, used_diff)</pre><pre>            # Option 2: take current element<br>            if prev_idx == -1:<br>                # First element of the subsequence<br>                res = max(res, 1 + dp(i + 1, i, used_diff))<br>            else:<br>                diff = abs(nums[i] - nums[prev_idx])<br>                if diff &lt;= 1:<br>                    res = max(res, 1 + dp(i + 1, i, used_diff))<br>                elif used_diff &lt; k:<br>                    # Allow a large jump if we have quota<br>                    res = max(res, 1 + dp(i + 1, i, used_diff + 1))</pre><pre>            return res</pre><pre>        return dp(0, -1, 0)</pre><h3>🧪 Example Walkthrough</h3><pre>python3</pre><pre>nums = [1, 4, 2, 3, 6, 5]<br>k = 1</pre><p>One possible subsequence is [1, 2, 3, 5]. Between 3 and 5, the difference is 2 — which is acceptable since k = 1.</p><p>So the maximum length of such a valid subsequence is <strong>4</strong>.</p><h3>Time &amp; Space Complexity</h3><ul><li><strong>Time Complexity</strong>: O(n^2 * k) — there are up to n positions, n possible previous indices, and k used_diff values.</li><li><strong>Space Complexity</strong>: O(n^2 * k) for memoization cache.</li></ul><h3>Summary</h3><p>LeetCode 3202 is a great example of using recursive state and memoization to efficiently solve problems involving constraints over subsequences. The key is to carefully define your state and ensure you’re not recalculating the same thing over and over.</p><p>If you found this useful, share with others and feel free to try writing a bottom-up tabulated version of the same logic as a follow-up challenge!</p><p><strong>Thanks for reading</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f86105f3366" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Static Website with NGINX on an Azure VM]]></title>
            <link>https://njange.medium.com/deploying-a-static-website-with-nginx-on-an-azure-vm-fd37a7a7f659?source=rss-ce8051390caf------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd37a7a7f659</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Njange]]></dc:creator>
            <pubDate>Thu, 30 Jan 2025 06:14:26 GMT</pubDate>
            <atom:updated>2025-01-30T06:14:26.119Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Deploying a web server is a fundamental DevOps skill, and this task involved setting up and configuring an NGINX server on an Ubuntu virtual machine (VM). The goal was to serve a custom HTML page and ensure accessibility through a public IP address. This blog post documents my approach, challenges faced, and key takeaways from the experience.</p><h3>Approach to Completing the Task</h3><h3>1. Provisioning an Azure Virtual Machine</h3><p>To begin, I created an Ubuntu VM on Azure and ensured it was reachable via SSH:</p><p><strong><em>ssh azureuser@http://&lt;ip address&gt;</em></strong></p><p>After confirming access, I updated the system packages:</p><p><strong><em>sudo apt update &amp;&amp; sudo apt upgrade -y</em></strong></p><h3>2. Installing and Configuring NGINX</h3><p>I installed NGINX using the following command:</p><p><strong><em>sudo apt install nginx -y</em></strong></p><p>Once installed, I started and enabled the NGINX service:</p><p><strong><em>sudo systemctl start nginx<br>sudo systemctl enable nginx</em></strong></p><h3>3. Creating a Custom HTML Page</h3><p>I modified the default NGINX landing page by creating a custom index.html file:</p><p><strong><em>echo “Welcome to DevOps Stage 0 — James Njange/njange” | sudo tee /var/www/html/index.html</em></strong></p><p>This ensured that navigating to the server’s IP address displayed the required message.</p><h3>4. Configuring the Firewall and Network Security Group (NSG)</h3><p>To allow HTTP traffic, I updated the firewall settings:</p><p><strong><em>sudo ufw allow ‘Nginx Full’</em></strong></p><p>On Azure, I verified the NSG rules and ensured port 80 was open:</p><p><strong><em>az network nsg rule list — resource-group HNGinternship — nsg-name HNG-nsg — output table</em></strong></p><p>Since there was an existing conflicting rule, I adjusted the priorities accordingly:</p><p><strong><em>az network nsg rule delete — resource-group HNGinternship — nsg-name HNG-nsg — name AllowHTTP<br>az network nsg rule create — resource-group HNGinternship — nsg-name HNG-nsg — name AllowHTTP — priority 110 — destination-port-ranges 80 — access Allow — protocol Tcp — direction Inbound</em></strong></p><h3>5. Restarting and Verifying NGINX</h3><p>After making the necessary changes, I restarted NGINX:</p><p><strong><em>sudo systemctl restart nginx</em></strong></p><p>Then, I verified that my page was accessible by running:</p><p><strong><em>curl -I </em></strong><a href="http://40.127.10.120/"><strong><em>http:/</em></strong></a><strong><em>/&lt;ip-address</em></strong></p><h3>Challenges and How I Overcame Them</h3><h3>1. Permission Issues with SSH</h3><p>Initially, I faced an SSH authentication error due to missing keys. I resolved this by ensuring my public key was added to the ~/.ssh/authorized_keys file and setting the correct file permissions:</p><p><strong><em>chmod 700 ~/.ssh<br>chmod 600 ~/.ssh/authorized_keys</em></strong></p><h3>2. NGINX Configuration Errors</h3><p>While testing the configuration, I encountered an error due to an invalid server_name directive. I fixed it by reviewing and correcting the /etc/nginx/sites-enabled/default file.</p><p><strong><em>sudo nginx -t<br>sudo systemctl restart nginx</em></strong></p><h3>3. Network Security Conflicts</h3><p>The initial NSG rule creation failed due to a conflict with an existing rule. I resolved this by adjusting rule priorities and deleting duplicate rules.</p><h3>Key Takeaways and Professional Growth</h3><p>This task reinforced my understanding of:</p><ul><li>Configuring and managing NGINX on a Linux server.</li><li>Working with Azure Virtual Machines and Network Security Groups.</li><li>Troubleshooting SSH and firewall issues.</li><li>Automating deployment steps for future projects.</li></ul><p>This experience is valuable in my journey toward becoming an<a href="https://hng.tech/hire/azure-devops-engineers"> Azure DevOps Engineer</a> and an<a href="https://hng.tech/hire/infrastructure-engineers"> Infrastructure Engineer</a>. It provided hands-on practice with cloud infrastructure, networking, and web server management — skills essential for DevOps roles.</p><h3>Conclusion</h3><p>By successfully deploying and configuring an NGINX web server on an Azure VM, I have gained practical experience in web hosting and cloud security. This task has strengthened my ability to troubleshoot real-world DevOps scenarios and has better prepared me for future cloud-based deployments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd37a7a7f659" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>