<?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 Dhaval Kumar on Medium]]></title>
        <description><![CDATA[Stories by Dhaval Kumar on Medium]]></description>
        <link>https://medium.com/@whym1here?source=rss-1c33c389e96a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FYFGDLssErR9OCEp3abZcw.jpeg</url>
            <title>Stories by Dhaval Kumar on Medium</title>
            <link>https://medium.com/@whym1here?source=rss-1c33c389e96a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:34:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@whym1here/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[Navigating the Zscaler Dev C Internship Interview Process]]></title>
            <link>https://medium.com/@whym1here/navigating-the-zscaler-dev-c-internship-interview-process-4bc1d6f611f5?source=rss-1c33c389e96a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bc1d6f611f5</guid>
            <category><![CDATA[c]]></category>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Dhaval Kumar]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 16:31:34 GMT</pubDate>
            <atom:updated>2024-01-16T16:31:34.477Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Zscaler Logo" src="https://cdn-images-1.medium.com/max/1024/1*5Xqx_xoUE26T4w19Q3RTPQ.jpeg" /><figcaption><a href="https://www.zscaler.com/company/about-zscaler">Source</a></figcaption></figure><p>A Deep Dive into Zscaler’s Dev C Internship Interview — From DSA to CS Fundamentals, Unraveling the Path to Success in Tech Assessments.</p><h3><strong>About the Opportunity:</strong></h3><p>In the last week of <strong>May 2023</strong>, Zscaler visited my college, IIIT Naya Raipur, in search of interns (2 month summer internship). They were recruiting for roles in <strong>Dev C</strong> and <strong>Dev Test</strong>.</p><h3>Online Assessment</h3><p><strong>Runtime:</strong> 2 hours</p><p>The online assessment consisted of <strong>four</strong> <strong>coding questions</strong> with varying difficulty levels —<strong> one easy</strong>, <strong>two medium</strong>, and <strong>one hard</strong>, all <strong>Leetcode-style problems</strong>.</p><h4><strong>Topics:</strong></h4><ol><li><a href="https://usaco.guide/bronze/ad-hoc?lang=cpp">Ad Hoc</a></li><li><a href="https://usaco.guide/silver/intro-bitwise?lang=cpp">Bit Masking</a></li><li><a href="https://usaco.guide/silver/binary-search?lang=cpp">Binary Search</a></li><li><a href="https://usaco.guide/bronze/intro-sets?lang=cpp">Sets, Maps</a> and <a href="https://usaco.guide/gold/hashmaps?lang=cpp">Hash Maps</a></li></ol><h4>Advice:</h4><ol><li><strong>Practice with Purpose:</strong> Focus on a variety of topics, including Ad Hoc, Bit Masking, Binary Search, Sets, Maps, Hash Maps, etc. Solving 200–300 Leetcode-style Medium and Hard problems will help you build a strong foundation.</li><li><strong>Time Management:</strong> During the assessment, manage your time wisely. Allocate a specific amount of time for each problem and move on if you get stuck.</li></ol><h4>Remarks:</h4><p>I successfully solved all the problems and qualified for the next round.</p><h3>Technical Interview (Round 1)</h3><p><strong>Runtime:</strong> 45 min</p><h4>Data Structures &amp; Algorithm:</h4><ol><li><a href="https://leetcode.com/problems/single-number/description/">Single Number Leetcode Easy</a></li><li><a href="https://leetcode.com/problems/search-a-2d-matrix-ii/">Search a 2D Matrix II Leetcode Medium</a></li></ol><h4>Computer Science Fundamentals:</h4><ol><li>Explain uses of Mutex and Semaphore.</li><li>Code Mutex and Semaphore in C Programming Language.</li><li>What is the role of Kernel in Operating System?</li><li>What tasks does Kernel performs when Operating System boots.</li><li>Differentiate between Multithreading and Multitasking.</li><li>Explain the use of Threading with example.</li><li>What is the role of Virtual Memory in Operating System?</li><li>Explain all the layers in TCP/IP stack and flow of data through each layers.</li></ol><h4>Advice:</h4><ol><li><strong>Master Operating Systems and Computer Networks:</strong> Invest time in understanding operating systems and computer networks thoroughly. Cover topics like Mutex, Semaphore, Kernel roles, Multithreading, Multitasking, Threading, Virtual Memory, TCP/IP stack, etc.</li><li><strong>Practice Explaining Concepts:</strong> Practice explaining concepts clearly. Use examples to illustrate your understanding of complex topics like TCP/IP layers.</li></ol><h4>Remarks:</h4><p>The <strong>Computer Science Fundamentals</strong> focused mainly on Operating Systems and Computer Networks. I was able to answer most of the questions, leading to my shortlisting for the next round.</p><h3>Technical Interview (Round 2)</h3><p><strong>Runtime:</strong> 45 min</p><h4>Data Structures &amp; Algorithm:</h4><ol><li>Given an <strong>IP Address</strong> in the form of a C string, convert and store it into a <strong>32-bit unsigned integer</strong>. (eg: char * ip = “17.172.224.47”, ans = 296542255).</li><li>Implement <strong>In-Place </strong><a href="https://www.spoj.com/problems/RUNLEN/"><strong>Run-length encoding (RLE)</strong></a> using any language.</li></ol><h4>C Programming Language:</h4><ol><li>How does addressing work in C?</li><li>Memory allocation in C.</li><li>Using a void pointer as a generic.</li><li>Mapping out the memory for a given struct.</li><li>How strings work in C.</li><li>Handling index out of bounds in C.</li><li>Communication between two C programs.</li></ol><h4>Advice:</h4><ol><li><strong>C/C++ Proficiency:</strong> Brush up on your C/C++ skills, especially focusing on pointers, memory allocation, stucts/unions, and string manipulation.</li><li><strong>Problem-Solving with Constraints:</strong> Understand how to solve problems efficiently in a constrained environment, as seen in the IP Address to 32-bit unsigned integer conversion question.</li><li><strong>In-depth C/C++ Knowledge:</strong> Be prepared to discuss in-depth topics like void pointers, struct memory mapping, and inter-process communication in C.</li></ol><h4>Remarks:</h4><p>This round primarily assessed my <strong>understanding of C/C++</strong> and involved questions about pointers, memory allocation, and deallocation. Successfully answering these questions led to my progression to the next round.</p><h3>Managerial Round (Round 3)</h3><p><strong>Runtime:</strong> 45 min</p><h4>Data Structures &amp; Algorithm:</h4><ol><li>Implement <strong>In Place </strong><a href="https://www.spoj.com/problems/RUNLEN/"><strong>Run-length encoding (RLE)</strong></a> using C Programming Language without any extra memory. (Interviewee expected to ask questions for clarification)</li></ol><h4>C Programming Language:</h4><ol><li>What is a function pointer? Code it in C and C++.</li><li>Consequences of not deallocating memory in C.</li><li>Implementation of most functions in C, taking printf as an example.</li></ol><h4>Advice:</h4><ol><li><strong>Effective Communication:</strong> In addition to technical skills, emphasize effective communication. Clearly ask clarifying questions when faced with a problem, as demonstrated in the RLE problem.</li><li><strong>Project Experience:</strong> If possible, work on a project using C or solve competitive programming or DSA problems in C. Practical experience is valuable.</li><li><strong>Understanding Functionality:</strong> For C-related questions, understand the implications of not deallocating memory and be able to implement common functions.</li></ol><h4>Remarks:</h4><p>This round focused on the <strong>RLE problem</strong> and its implementation in C. The interviewer expected me to <strong>ask clarifying questions</strong>, which helped in solving the problem effectively. The round was conducted by a Manager.</p><h3>Conclusion:</h3><p>Participating in the interview at Zscaler was a valuable and rewarding opportunity. After successfully completing the three rounds, I received an offer from Zscaler.</p><h4>Overall Advice:</h4><ol><li><strong>Holistic Preparation:</strong> Balance your preparation between coding challenges, theoretical knowledge, and practical problem-solving.</li><li><strong>Stay Calm and Engage:</strong> During interviews, remain calm and engage with the interviewer. It’s crucial to showcase not only technical skills but also your ability to think on your feet.</li><li><strong>Continuous Learning:</strong> Keep learning and adapting. The tech industry evolves rapidly, and staying updated will enhance your problem-solving abilities.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bc1d6f611f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to convert almost all Recursive DP to Iterative DP]]></title>
            <link>https://medium.com/@whym1here/how-to-convert-almost-all-recursive-dp-to-iterative-dp-babaaff0363d?source=rss-1c33c389e96a------2</link>
            <guid isPermaLink="false">https://medium.com/p/babaaff0363d</guid>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[memory-optimization]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Dhaval Kumar]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 05:31:31 GMT</pubDate>
            <atom:updated>2023-06-23T05:31:31.676Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhOwEO1ZeKjCopQ1J9T6og.jpeg" /><figcaption>Fractal Recursive Geometry</figcaption></figure><p>In this article we will discuss how to convert almost all Recursive Dynamic Programming Solutions to Iterative Dynamic Programming Solutions with memory optimization through a <a href="https://leetcode.com/"><strong>Leetcode</strong></a> problem <a href="https://leetcode.com/problems/painting-the-walls/description/"><strong>Painting the Walls</strong></a>. I would recommend you to try the problem first by yourself then revisit this article.</p><h3>Why do you need to learn this?</h3><p>One of the major obstacles I encountered during my journey with Dynamic Programming was the ease with which I could develop <strong>Recursive + Memoization solutions</strong>, contrasted by the difficulty I faced when attempting to convert them into iterative ones. Initially, this issue did not impede my progress. However, as I delved deeper into problem-solving, I encountered a few scenarios that <strong>necessitated memory optimization.</strong></p><p>After scouring the web for guidance, I discovered a <strong>crucial limitation of Recursive + Memoization Solutions</strong>: <a href="https://codeforces.com/blog/entry/84106?#comment-716104">they do not lend themselves well to memory optimization techniques</a>. The inherent nature of recursive calls coupled with memoization, while efficient in terms of time complexity, can lead to excessive memory consumption.</p><p>This becomes particularly relevant for online assessments (OAs) and interviews where candidates are often expected to produce memory-optimized solutions to DP problems. Additionally, Python users may face the challenge of having to write iterative DP solutions to meet the constraints of certain online judges problems.</p><h3><strong>Painting the Walls</strong></h3><p>As the problems states, we have a list of walls to be painted, and for each wall, we know the cost and time it takes to paint it. We have <strong>two painters</strong> available: <strong>one who charges money for painting each wall based on the cost and time</strong>, and <strong>another who paints walls for free but takes 1 unit of time</strong> to do so.</p><p>The catch is that the <strong>free painter can only work if the paid painter is already occupied with another wall</strong>.</p><p>Our goal is to determine the <strong>minimum amount of money required</strong> to paint all the walls.</p><p>The problem is not that relevant to the technique. As this can be applied to almost any problem. What’s relevant here are the steps or things to keep in mind while preforming the conversion and applying the optimization.</p><h3>Approach</h3><p>This problem is a variation of <a href="https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/"><strong>0/1 Knapsack Problem</strong></a> in which we can define our states as:</p><pre>// Recurrence Relation<br>f(index, total_time, took) = min(<br>  f(index + 1, min(total_time + 1 + time[i], n), 1) + cost[i],<br>  f(index + 1, total_time, 0)<br>)<br><br>// Base Case<br>if (total_time == n) f(index, total_time, took) = 0<br>if (i == n and total_time != n) f(index, total_time, took) = INF</pre><ul><li>index: Represents the index of the current wall we are considering. It ranges from 0 to n-1, where n is the total number of walls.</li><li>total_time: Indicates the total time taken to paint the walls up to the current index. This value is updated as we progress through the walls.</li><li>took: Denotes whether the paid painter has been occupied (1) or not (0) for the current wall.</li></ul><p>The recurrence relation computes the minimum cost at each step by considering two scenarios:</p><ol><li><strong>Paying the painter for the wall:</strong> This option takes into account the cost and time required to paint the wall. By paying the painter, we get the time needed to paint the wall, which can then be used to paint subsequent walls.</li><li><strong>Not paying the painter for the wall:</strong> This option assumes that previous walls have given us extra time or we will get extra time for another wall with paid painter, which can be used to paint the current wall without incurring any additional cost.</li></ol><p>The base cases handle the termination conditions:</p><ol><li>If the total time taken equals the total number of walls, the cost is 0 since all walls have been painted within the given time.</li><li>If the index reaches the total number of walls but the total time taken does not equal the total number of walls, it signifies an invalid solution, so we assign a value of infinity (INF) to indicate that.</li></ol><blockquote><strong>NOTE: </strong>You can eliminate the took form the recurrence. Can you reason why? Maybe study about the <a href="https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/"><strong>0/1 Knapsack Problem</strong></a> recurrence.</blockquote><h3>Recursive + Memoization Approach</h3><p>This just the implementation of the approach discussed above.</p><p><strong>Complexities:</strong></p><ul><li>Time Complexity: <strong>O(n²)</strong></li><li>Space Complexity: <strong>O(n²)</strong></li></ul><pre>const int mxn = 501;<br>int dp[mxn][mxn][2];<br><br>class Solution {<br>public:<br>    int paintWalls(vector&lt;int&gt;&amp; cost, vector&lt;int&gt;&amp; time) {<br>        const int n = (int)cost.size();<br>        memset(dp, -1, sizeof dp);<br>        function&lt;int(int, int, int)&gt; f = [&amp;](int i, int tot, int t) -&gt; int {<br>            if (tot == n) return 0;<br>            if (i == n) return 1e9; // INF<br>            int&amp; ans = dp[i][tot][t];<br>            if (ans != -1) return ans;<br>            ans = min(<br>                f(i + 1, min(tot + 1 + time[i], n), 1) + cost[i], <br>                f(i + 1, tot, 0)<br>            );<br>            return ans;<br>        };<br>        return f(0, 0, 0);<br>    }<br>};</pre><h3>Iterative Approach</h3><p>To convert recursive approach to iterative approach you need to keep in mind:</p><ol><li><strong>Execution of states in DP:</strong> In DP, the states are typically executed in a bottom-up manner, starting from the base cases and progressing towards the final desired state. This means that the answer for the last states is usually calculated first.</li><li><strong>Base cases:</strong> Base cases represent the termination conditions for the DP algorithm. They need to be initialized first before computing other states. Base cases handle scenarios where the state variables reach specific values or certain conditions are met. Proper initialization of base cases ensures the DP algorithm functions correctly.</li><li><strong>Number of variables in states vs. loops:</strong> The number of variables in the DP states may not always match the number of loops in the iterative solution. Depending on the problem’s requirements, multiple loops might be necessary to cover all the dimensions of the state space. Each loop iterates over a specific variable, allowing the DP algorithm to explore all possible combinations of states and compute the optimal solution.</li></ol><p><strong>Complexities:</strong></p><ul><li>Time Complexity: <strong>O(n²)</strong></li><li>Space Complexity: <strong>O(n²)</strong></li></ul><pre>const int mxn = 501;<br>int dp[mxn][mxn][2];<br><br>class Solution {<br>public:<br>    int paintWalls(vector&lt;int&gt;&amp; cost, vector&lt;int&gt;&amp; time) {<br>        const int n = (int)cost.size();<br>        for (int i = n; i &gt;= 0; i--) {<br>            for (int tot = n; tot &gt;= 0; tot--) {<br>                for (int t = 0; t &lt; 2; t++) {<br>                    dp[i][tot][t] = (tot == n? 0: 1e9); // base case<br>                    // to avoid mistakes handle base cases separately <br>                    // in other words use different loops for it <br>                    if (i == n) continue;<br>                    dp[i][tot][t] = min(<br>                        dp[i + 1][min(tot + 1 + time[i], n)][1] + cost[i],<br>                        dp[i + 1][tot][0]<br>                    );<br>                }<br>            }<br>        }<br>        return dp[0][0][0];<br>    }<br>};</pre><h3>Iterative with Memory Optimization Approach</h3><p>Now for the memory optimization part:</p><ol><li><strong>Memory Optimization:</strong> To optimize memory usage, it is important to identify if some states in the DP algorithm only depend on the state just before them. This indicates that one state can be removed from the DP array, saving space.</li><li><strong>Implementation: </strong>To achieve memory optimization, two different arrays or a single array with two dimensions at the front can be used. By using 0 (even) and 1 (odd) indices, the optimization can be incorporated into the code.</li><li><strong>Process: </strong>The code snippet provided demonstrates the memory optimization technique. By using the bitwise operator &amp; with 1, the index i is toggled between 0 and 1. This allows for accessing the correct states in the DP array while eliminating the need for an additional dimension. The optimization is applied in the nested loops where dp[i] and dp[1 - i] are used to alternate between the two arrays or sections of the array, reducing the memory usage.</li></ol><p><strong>Complexities:</strong></p><ul><li>Time Complexity: <strong>O(n²)</strong></li><li>Space Complexity: <strong>O(n)</strong></li></ul><pre>const int mxn = 501;<br>int dp[2][mxn][2]; // memory optimization<br><br>class Solution {<br>public:<br>    int paintWalls(vector&lt;int&gt;&amp; cost, vector&lt;int&gt;&amp; time) {<br>        const int n = (int)cost.size();<br>        for (int idx = n; idx &gt;= 0; idx--) {<br>            for (int tot = n; tot &gt;= 0; tot--) {<br>                for (int t = 0; t &lt; 2; t++) {<br>                    int i = idx &amp; 1;<br>                    dp[i][tot][t] = (tot == n? 0: 1e9); // base case<br>                    // to avoid mistakes handle base cases separately <br>                    // in other words use different loops for it<br>                    if (idx == n) continue;<br>                    dp[i][tot][t] = min(<br>                        dp[1 - i][min(tot + 1 + time[idx], n)][1] + cost[idx],<br>                        dp[1 - i][tot][0]<br>                    ); <br>                }<br>            }<br>        }<br>        return dp[0][0][0];<br>    }<br>};</pre><h3><strong>Conclusion</strong></h3><p>In this article we discussed a method to convert almost all recursive dynamic programming (DP) solutions into iterative ones. However, it’s important to note that this conversion is not always necessary, some DP problems do not require it and sometimes it may be really difficult to implement. An alternative approach to improving your DP skills is to practice thinking iteratively from the get go. <a href="https://www.youtube.com/watch?v=Clp5c7HvLqs"><strong>Dynamic Programming Made Simple [Intro / Overview]</strong></a> by <a href="https://www.youtube.com/watch?v=Clp5c7HvLqs"><strong>Colin Galen</strong></a><strong> </strong>and <a href="https://www.youtube.com/watch?v=U4O3SwDamA4"><strong>Episode 19 — Knapsack</strong></a> by <a href="https://www.youtube.com/@AlgorithmsLive"><strong>Algorithms Live!</strong></a><strong> </strong>are different perspectives on writing DP and also great resources to learn a bit more about DP.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=babaaff0363d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>