<?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 Shubhi Jain on Medium]]></title>
        <description><![CDATA[Stories by Shubhi Jain on Medium]]></description>
        <link>https://medium.com/@shubhijain?source=rss-964e7192f737------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rIrqpVzSBG_Ldgis0cLLgw.jpeg</url>
            <title>Stories by Shubhi Jain on Medium</title>
            <link>https://medium.com/@shubhijain?source=rss-964e7192f737------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:59:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubhijain/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[The Databases Every Developer Should Master Before an Interview]]></title>
            <link>https://medium.com/@shubhijain/the-databases-every-developer-should-master-before-an-interview-f92de299e13d?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/f92de299e13d</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Sun, 08 Feb 2026 19:47:20 GMT</pubDate>
            <atom:updated>2026-02-08T19:47:20.432Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Rule of interviews:</strong><br> You’re not judged on <em>how many</em> databases you know — <br> you’re judged on <em>why you’d choose one over another</em>.</p><h3>SQL / Relational Databases</h3><h3>1. MySQL</h3><p><strong>What it is:</strong> Popular open-source relational database.</p><p><strong>Key points:</strong></p><ul><li>Uses structured schema with tables and relationships</li><li>Supports transactions and ACID guarantees</li><li>Uses B-Tree indexes for fast lookups</li><li>Widely used in web applications</li></ul><p><strong>Interview focus:</strong></p><ul><li>How indexes improve performance</li><li>Difference between INNER, LEFT, RIGHT joins</li><li>When queries become slow and how to optimize them</li></ul><h3>2. PostgreSQL</h3><p><strong>What it is:</strong> Advanced, enterprise-grade relational database.</p><p><strong>Key points:</strong></p><ul><li>Strong consistency and correctness</li><li>MVCC allows high concurrency without heavy locking</li><li>Supports complex queries (CTEs, window functions)</li><li>Can store JSON while still being relational</li></ul><p><strong>Interview focus:</strong></p><ul><li>Why Postgres handles concurrency better than MySQL</li><li>SQL vs JSONB use cases</li><li>Isolation levels and locks</li></ul><h3>3. SQLite</h3><p><strong>What it is:</strong> Embedded, file-based relational database.</p><p><strong>Key points:</strong></p><ul><li>No server process — database is a single file</li><li>Very low setup and maintenance</li><li>Limited concurrent writes</li><li>Extremely reliable for small-scale apps</li></ul><p><strong>Interview focus:</strong></p><ul><li>Why SQLite is great for mobile/testing</li><li>Why it fails at high concurrency</li><li>Difference between embedded vs server DBs</li></ul><h3>NoSQL Databases</h3><h3>4. MongoDB (Document DB)</h3><p><strong>What it is:</strong> Schema-flexible document database.</p><p><strong>Key points:</strong></p><ul><li>Stores data as JSON-like documents</li><li>Supports secondary indexes</li><li>Powerful aggregation pipeline</li><li>Scales horizontally easily</li></ul><p><strong>Interview focus:</strong></p><ul><li>Schema design even in schema-less systems</li><li>MongoDB vs SQL trade-offs</li><li>Why joins are limited and expensive</li></ul><h3>5. DynamoDB</h3><p><strong>What it is:</strong> Fully managed NoSQL key-value DB by AWS.</p><p><strong>Key points:</strong></p><ul><li>Designed for massive scale</li><li>Data distribution based on partition key</li><li>Very fast predictable performance</li><li>Limited query flexibility</li></ul><p><strong>Interview focus:</strong></p><ul><li>Importance of partition key design</li><li>Hot partition problem</li><li>Strong vs eventual consistency</li></ul><h3>6. Cassandra</h3><p><strong>What it is:</strong> Distributed wide-column database.</p><p><strong>Key points:</strong></p><ul><li>Built for high availability and fault tolerance</li><li>Optimized for writes</li><li>No single point of failure</li><li>Eventually consistent by default</li></ul><p><strong>Interview focus:</strong></p><ul><li>CAP theorem (AP system)</li><li>Why Cassandra avoids joins</li><li>Use cases like logs, metrics, large writes</li></ul><h3>In-Memory / Performance-Oriented</h3><h3>7. Redis</h3><p><strong>What it is:</strong> In-memory key-value data store.</p><p><strong>Key points:</strong></p><ul><li>Extremely fast (RAM-based)</li><li>Supports data structures (lists, sets, hashes)</li><li>Used as cache, queue, session store</li><li>Can persist data to disk</li></ul><p><strong>Interview focus:</strong></p><ul><li>Cache eviction strategies (TTL, LRU)</li><li>Redis vs database caching</li><li>Use in rate limiting and distributed locks</li></ul><h3>Search &amp; Graph</h3><h3>8. Elasticsearch</h3><p><strong>What it is:</strong> Distributed search and analytics engine.</p><p><strong>Key points:</strong></p><ul><li>Uses inverted indexes</li><li>Optimized for text search</li><li>Near real-time querying</li><li>Scales horizontally via shards</li></ul><p><strong>Interview focus:</strong></p><ul><li>Why it’s not a primary database</li><li>Full-text search vs SQL LIKE queries</li><li>Shards, replicas, and consistency</li></ul><h3>9. Neo4j (Graph DB)</h3><p><strong>What it is:</strong> Graph-based database for relationships.</p><p><strong>Key points:</strong></p><ul><li>Data stored as nodes and relationships</li><li>Fast traversal of connected data</li><li>Uses Cypher query language</li><li>Excellent for complex relationships</li></ul><p><strong>Interview focus:</strong></p><ul><li>Why graph DBs beat SQL for deep relationships</li><li>Use cases like social graphs, fraud detection</li><li>Performance advantage of graph traversal</li></ul><h3>Real-Time / Frontend-Friendly</h3><h3>10. Firebase / Firestore</h3><p><strong>What it is:</strong> Cloud-hosted NoSQL document DB.</p><p><strong>Key points:</strong></p><ul><li>Real-time data synchronization</li><li>Tight integration with frontend apps</li><li>Serverless and auto-scaling</li><li>Limited querying capabilities</li></ul><p><strong>Interview focus:</strong></p><ul><li>Trade-offs of real-time updates</li><li>Security rules importance</li><li>Vendor lock-in concerns</li></ul><h3>Time-Series Databases</h3><h3>11. InfluxDB</h3><p><strong>What it is:</strong> Time-series optimized database.</p><p><strong>Key points:</strong></p><ul><li>Stores data indexed by time</li><li>Efficient for writes and time-range queries</li><li>Built-in retention policies</li><li>Optimized for metrics data</li></ul><p><strong>Interview focus:</strong></p><ul><li>Why relational DBs are bad for metrics</li><li>Retention and down-sampling</li><li>Use cases in monitoring and IoT</li></ul><h3>Analytics &amp; Warehousing</h3><h3>12. Snowflake / BigQuery</h3><p><strong>What it is:</strong> Cloud-native data warehouse.</p><p><strong>Key points:</strong></p><ul><li>Columnar storage</li><li>Optimized for analytics, not transactions</li><li>Separates compute from storage</li><li>Handles massive datasets efficiently</li></ul><p><strong>Interview focus:</strong></p><ul><li>OLTP vs OLAP differences</li><li>Why columnar storage is faster for analytics</li><li>Cost-performance trade-offs</li></ul><h3>Interview Power Questions (Must-Answer)</h3><ul><li>Why choose SQL vs NoSQL here?</li><li>How does this DB scale?</li><li>How is data partitioned?</li><li>What consistency guarantees exist?</li><li>When would this DB fail badly?</li></ul><h3>Final Thought</h3><p>If you can <strong>explain one database deeply</strong> and <strong>compare it confidently with others</strong>, you’ll outperform candidates who just list names.</p><p><em>That’s all for this article. Hope you liked it.</em></p><p>You Can Follow <a href="https://medium.com/@shubhijain"><strong>Shubhi</strong></a> For More Such Content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f92de299e13d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Generative AI Goes Multimodal: Beyond Words to Worlds]]></title>
            <link>https://medium.com/@shubhijain/generative-ai-goes-multimodal-beyond-words-to-worlds-ffe450b55c48?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffe450b55c48</guid>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[future-technology]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tech-innovation]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Tue, 09 Dec 2025 05:53:04 GMT</pubDate>
            <atom:updated>2025-12-09T05:53:04.053Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vVTXMUfPJUn4azbf" /><figcaption>Photo by <a href="https://unsplash.com/@steve_j?utm_source=medium&amp;utm_medium=referral">Steve Johnson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Generative AI has taken the tech world by storm, but its evolution into <strong>multimodal AI</strong> is the real game-changer. No longer limited to text, these advanced models now combine <strong>text 📝, images 🖼️, audio 🎵, and video 🎬</strong> to create rich, interactive experiences. This shift is redefining creativity, marketing, education, and entertainment.</p><h3>What Is Multimodal AI?</h3><p>Multimodal AI refers to systems that process and generate content across multiple data types simultaneously. Instead of working in silos — text-only or image-only — these models integrate different modalities to produce cohesive outputs. For example:</p><ul><li>A single prompt can generate a <strong>blog post + infographic + voice narration</strong>.</li><li>A video can be created from a <strong>script + background music + visual effects</strong>, all powered by AI.</li></ul><h3>Why It Matters</h3><p>The ability to merge modalities unlocks :</p><ul><li><strong>Hyper-Personalization:</strong> Tailored content for marketing and education.</li><li><strong>Speed:</strong> Campaigns and creative assets in hours, not weeks.</li><li><strong>Immersion:</strong> Gaming and AR/VR experiences that feel real.</li></ul><h3>Real-World Examples</h3><ol><li><strong>Marketing Magic</strong><br> Brands like <strong>Nike</strong> leveraged multimodal AI for its <em>“Never Done Evolving”</em> campaign, blending video, text overlays, and audio cues to achieve record engagement.</li><li><strong>Education Reinvented</strong><br> AR/VR classrooms powered by multimodal AI deliver synchronized diagrams and voice narration, making complex topics easier to grasp.</li><li><strong>Gaming Gets Smarter</strong><br> Platforms like <strong>Inworld AI</strong> and <strong>NVIDIA Omniverse</strong> allow developers to generate 3D assets and adaptive storylines from text prompts, cutting production time dramatically.</li></ol><h3>Techniques Behind Multimodal AI</h3><p>Multimodal AI combines several advanced architectures:</p><ul><li><strong>Transformers</strong>: Handle sequential data and context across modalities.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GY8_7IO8eQbd3wxn" /><figcaption>Photo by <a href="https://unsplash.com/@tetrakiss?utm_source=medium&amp;utm_medium=referral">Arseny Togulev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ul><li><strong>Diffusion Models</strong>: Generate high-quality images and videos by reversing noise processes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AjXIDIBzHQLtL-Ha" /><figcaption>Photo by <a href="https://unsplash.com/@steve_j?utm_source=medium&amp;utm_medium=referral">Steve Johnson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ul><li><strong>GANs (Generative Adversarial Networks)</strong>: Integrate text, image, and style for realistic outputs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1ENIgUe1wi34BeVf" /><figcaption>Photo by <a href="https://unsplash.com/@guerrillabuzz?utm_source=medium&amp;utm_medium=referral">GuerrillaBuzz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ul><li><strong>Cross-Modal Embeddings</strong>: Align text and image representations for coherent generation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x5n4aF8MeaJDqF04" /><figcaption>Photo by <a href="https://unsplash.com/@kanhaiyasharma?utm_source=medium&amp;utm_medium=referral">Kanhaiya Sharma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ul><li><strong>Attention Mechanisms</strong>: Enable models to focus on relevant parts of each modality simultaneously.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LULU-7WmtGGURn9C" /><figcaption>Photo by <a href="https://unsplash.com/@jakubzerdzicki?utm_source=medium&amp;utm_medium=referral">Jakub Żerdzicki</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Tools Powering Multimodal AI</h3><ul><li><strong>GPT-5</strong>: Advanced language model with multimodal capabilities.</li><li><strong>Stable Diffusion</strong>: Text-to-image generation with diffusion-based architecture.</li><li><strong>Inworld AI</strong>: Creates interactive, emotionally expressive AI characters for games.</li><li><strong>NVIDIA Omniverse</strong>: Enables real-time 3D asset generation and simulation.</li></ul><h3>Challenges Ahead</h3><ul><li><strong>Data Complexity:</strong> Training requires massive, diverse datasets.</li><li><strong>Ethical Concerns:</strong> Ensuring fairness and avoiding bias in multimodal outputs.</li><li><strong>Compute Costs:</strong> High resource demands for large-scale models.</li></ul><h3>Future Outlook</h3><p>Expect multimodal AI to dominate:</p><ul><li><strong>E-Commerce:</strong> Personalized product demos with text, visuals, and voice.</li><li><strong>Healthcare:</strong> AI-generated reports with annotated images and audio explanations.</li></ul><h3>Conclusion</h3><p>Generative AI’s leap into multimodality is not just an upgrade — it’s a revolution. It empowers creators, accelerates workflows, and opens doors to experiences we’ve only imagined. The future of creativity is <strong>multimodal, intelligent, and limitless</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffe450b55c48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Find the Punishment Number of an Integer || LeetCode]]></title>
            <link>https://medium.com/operations-research-bit/find-the-punishment-number-of-an-integer-leetcode-078ee5b57020?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/078ee5b57020</guid>
            <category><![CDATA[problem-of-the-day]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[backtracking]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Sat, 15 Feb 2025 20:44:50 GMT</pubDate>
            <atom:updated>2025-05-04T02:13:14.880Z</atom:updated>
            <content:encoded><![CDATA[<h4>Given a positive integer n, return <em>the </em><strong><em>punishment number</em></strong> of n.</h4><p>The <strong>punishment number</strong> of n is defined as the sum of the squares of all integers i such that:<br>1. 1≤i≤n<br>2. The decimal representation of i * i can be partitioned into contiguous substrings such that the sum of the integer values of these substrings equals i.</p><pre>Example 1:<br><br>Input: n = 10<br>Output: 182<br>Explanation: There are exactly 3 integers i in the range [1, 10] <br>that satisfy the conditions in the statement:<br>- 1 since 1 * 1 = 1<br>- 9 since 9 * 9 = 81 and 81 can be partitioned into 8 and 1 with a <br>  sum equal to 8 + 1 == 9.<br>- 10 since 10 * 10 = 100 and 100 can be partitioned into 10 and 0 with a <br>  sum equal to 10 + 0 == 10.<br>Hence, the punishment number of 10 is 1 + 81 + 100 = 182<br><br>Example 2:<br><br>Input: n = 37<br>Output: 1478<br>Explanation: There are exactly 4 integers i in the range [1, 37] that satisfy the conditions in the statement:<br>- 1 since 1 * 1 = 1. <br>- 9 since 9 * 9 = 81 and 81 can be partitioned into 8 + 1. <br>- 10 since 10 * 10 = 100 and 100 can be partitioned into 10 + 0. <br>- 36 since 36 * 36 = 1296 and 1296 can be partitioned into 1 + 29 + 6.<br>Hence, the punishment number of 37 is 1 + 81 + 100 + 1296 = 1478</pre><h4>Intution</h4><p>The goal is to sum all the numbers between 1 to n which satisfy 2 conditions mentioned in question. Firstly we need to check for all numbers in between 1 and n, so we need to compute the 2nd condition for all the numbers b/w 1 to n. And since, there are multiple ways to partition a number, we use a recursive <strong>backtracking approach</strong> to explore all possibilities. <em>That’s all for this article. Hope you liked it.</em></p><h4>Algorithm</h4><ol><li><strong>Initialize </strong><strong>total = 0</strong> to store the sum of valid squares.</li><li><strong>Iterate over all numbers</strong> from 1 to n.<br>. Compute i².<br>. Check if i² can be partitioned such that the sum of partitions equals i using canPartition(i, i^2).<br>. If valid, add i² to total.</li><li>Call a recursive function backtrack(target, remaining, currentSum), where:<br>. target = i (the number we are checking).<br>. remaining = i² (the number we need to partition).<br>. currentSum = 0 (tracks the running sum).</li></ol><p>Recursive Backtracking for Partitioning (backtrack function)</p><ol><li>If remaining == 0:<br>. If currentSum == target, return true (valid partitioning found).<br>. Else, return false.</li><li>Initialize tempSum = 0 and place = 1.</li><li>While remaining &gt; 0:<br>. Extract the last digit using remaining % 10.<br>. Form a new number tempSum = digit * place + tempSum.<br>. Remove the last digit from remaining using remaining / 10.</li><li>If currentSum + tempSum &gt; target, stop this path (prune unnecessary work).</li><li>Otherwise, <strong>recur</strong> by calling backtrack(target, remaining, currentSum + tempSum).</li><li>If any recursive call returns true, return true.</li><li>Continue forming larger numbers by increasing place *= 10.</li></ol><h4>Solution</h4><pre>public class PunishmentNumber {<br>    public static boolean canPartition(int num, int square) {<br>        return backtrack(num, square, 0);<br>    }<br><br>    private static boolean backtrack(int target, int remaining, int currentSum) {<br>        if (remaining == 0) {<br>            return currentSum == target;<br>        }<br><br>        int tempSum = 0;<br>        int place = 1; // To extract digit groups<br><br>        while (remaining &gt; 0) {<br>            int digit = remaining % 10;<br>            tempSum = digit * place + tempSum;<br>            remaining /= 10;<br><br>            if (currentSum + tempSum &gt; target) {<br>                break;<br>            }<br>            if (backtrack(target, remaining, currentSum + tempSum)) {<br>                return true;<br>            }<br><br>            place *= 10; // Move to the next place value<br>        }<br>        return false;<br>    }<br><br>    public static int punishmentNumber(int n) {<br>        int total = 0;<br>        for (int i = 1; i &lt;= n; i++) {<br>            int square = i * i;<br>            if (canPartition(i, square)) {<br>                total += square;<br>            }<br>        }<br>        return total;<br>    }<br><br>    public static void main(String[] args) {<br>        System.out.println(punishmentNumber(10)); // Output: 182<br>    }<br>}<br></pre><h4><strong>Space and Time Complexity</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*mErWA1_NncgIXKzZETRx5Q.png" /></figure><p>You Can Follow <a href="https://medium.com/@shubhijain"><strong>Shubhi</strong></a> For More Such Content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=078ee5b57020" width="1" height="1" alt=""><hr><p><a href="https://medium.com/operations-research-bit/find-the-punishment-number-of-an-integer-leetcode-078ee5b57020">Find the Punishment Number of an Integer || LeetCode</a> was originally published in <a href="https://medium.com/operations-research-bit">Operations Research Bit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design patterns for microservices]]></title>
            <link>https://medium.com/@shubhijain/design-patterns-for-microservices-0d978303c343?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d978303c343</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Tue, 12 Nov 2024 09:56:00 GMT</pubDate>
            <atom:updated>2024-11-17T01:36:13.808Z</atom:updated>
            <content:encoded><![CDATA[<p>Design patterns for microservices are key to creating scalable, maintainable, and efficient distributed systems. These patterns address challenges specific to microservices architecture, such as service communication, data consistency, fault tolerance, scalability, and security.</p><p><strong>Below are some commonly used design patterns for microservices:</strong></p><h3>1. API Gateway Pattern</h3><ol><li><strong>Purpose</strong>: To handle requests from clients and route them to appropriate microservices.</li><li><strong>Description</strong>: An API Gateway acts as a reverse proxy, routing client requests to the appropriate microservice. It can aggregate responses, handle cross-cutting concerns like authentication, logging, rate limiting, etc.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Centralized management of API requests.</li><li>Simplifies client interactions with multiple services (client calls only to the API Gateway).</li><li>Common in scenarios with multiple microservices providing different functionality.</li></ul><h3>2. Database per Service Pattern</h3><ol><li><strong>Purpose</strong>: Each microservice has its own dedicated database to ensure loose coupling.</li></ol><p><strong>2. Description</strong>: In a microservices architecture, each service should have its own database (whether SQL, NoSQL, etc.). This avoids tight coupling between services that could result from sharing a database and ensures that each service can evolve independently.</p><p><strong>3. Use Cases</strong>:</p><ul><li>When services need to operate independently and have different data storage needs.</li><li>When you want to reduce contention for shared resources and avoid downtime due to database schema changes.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Managing data consistency across services.</li><li>Complex queries across multiple databases.</li></ul><h3>3. CQRS (Command Query Responsibility Segregation) Pattern</h3><ol><li><strong>Purpose</strong>: To separate the read and write operations of a system.</li><li><strong>Description</strong>: In CQRS, commands (write operations) are separated from queries (read operations). This allows optimizing each operation type independently and can improve performance, scalability, and maintainability.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Complex applications with distinct read and write requirements (e.g., high-volume reads and low-volume writes).</li><li>Systems requiring different models for reading and writing data (e.g., read-heavy systems).</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Increased complexity due to maintaining separate models.</li><li>Potential eventual consistency issues.</li></ul><h3>4. Event Sourcing Pattern</h3><ol><li><strong>Purpose</strong>: To persist the state of an application by storing the events that led to the state rather than the state itself.</li><li><strong>Description</strong>: Instead of saving the current state of a system in a database, event sourcing stores a series of events that lead to the current state. This pattern is particularly useful when the system’s state needs to be reconstructed or replayed.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Systems that require auditing and traceability.</li><li>Systems with complex business logic and where replaying events is needed for debugging or recovery.</li></ul><p>4. <strong>Challenges</strong>:</p><ul><li>Managing large volumes of events.</li><li>Ensuring eventual consistency and addressing data corruption issues.</li></ul><h3>5. Saga Pattern</h3><ol><li><strong>Purpose</strong>: To manage long-running transactions across microservices in a reliable manner.</li><li><strong>Description</strong>: A saga is a sequence of local transactions where each service involved in the saga performs its transaction and publishes an event or calls the next service in the sequence. If a failure occurs, compensating transactions are triggered to undo the work.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Systems that require distributed transactions or coordination between microservices.</li><li>Implementing workflows or business processes that span multiple services.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Ensuring data consistency in case of failures.</li><li>Complex orchestration and monitoring.</li></ul><h3>6. Circuit Breaker Pattern</h3><ol><li><strong>Purpose</strong>: To handle failures and prevent cascading failures in distributed systems.</li><li><strong>Description</strong>: A circuit breaker monitors the interactions between microservices. If a service becomes unreliable or fails, the circuit breaker “opens,” and further requests to the service are rejected or routed elsewhere, preventing further strain on the failing service and allowing it to recover.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Preventing system-wide failures when a service is experiencing issues.</li><li>Providing graceful degradation of service during failures.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Fine-tuning the timeout, retry, and fallback mechanisms.</li><li>Complexity in handling various types of failures.</li></ul><h3>7. Strangler Fig Pattern</h3><ol><li><strong>Purpose</strong>: To incrementally refactor a monolithic application into microservices without requiring a complete rewrite.</li><li><strong>Description</strong>: This pattern suggests incrementally replacing parts of the legacy monolithic system with microservices, rather than doing a complete rewrite. The new services “strangle” the old monolithic system as they take over different parts of the business logic and features.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Gradual migration from a monolithic architecture to microservices.</li><li>Modernizing legacy systems with minimal disruption.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Managing two parallel systems (legacy and microservices) for a while.</li><li>Coordination between old and new components during the transition.</li></ul><h3>8. Service Discovery Pattern</h3><ol><li><strong>Purpose</strong>: To enable microservices to find each other dynamically at runtime.</li><li><strong>Description</strong>: Service discovery allows microservices to register themselves and discover other services without needing hardcoded IP addresses or domain names. This can be done using tools like Consul, Eureka, or Kubernetes service discovery.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Environments where services scale up and down dynamically, making static IP addresses unreliable.</li><li>Distributed systems where the location of services changes frequently.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Ensuring the discovery mechanism is fast and reliable.</li><li>Managing failures when services cannot be discovered.</li></ul><h3>9. Shared Library Pattern</h3><ol><li><strong>Purpose</strong>: To share common logic across services.</li><li><strong>Description</strong>: This pattern involves creating shared libraries or frameworks that contain common functionality (e.g., logging, authentication, validation) which can be used by multiple microservices to ensure consistency and avoid duplication of effort.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Sharing common code (e.g., validation, logging, error handling) across multiple microservices.</li><li>Ensuring consistency in behavior across different services.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Maintaining versioning and backward compatibility of shared libraries.</li><li>Risk of tight coupling if not managed properly.</li></ul><h3>10. Bulkhead Pattern</h3><ol><li><strong>Purpose</strong>: To isolate and limit the failure of services or resources within a system.</li><li><strong>Description</strong>: The bulkhead pattern involves isolating parts of the system so that a failure in one part does not bring down the entire system. It’s commonly used to segment resources (e.g., thread pools, databases) or service instances to limit the impact of failure.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Avoiding single points of failure.</li><li>Protecting critical services from cascading failures in other parts of the system.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Proper resource allocation to avoid overloading.</li><li>Complexity in isolating and managing resources.</li></ul><h3>11. Sidecar Pattern</h3><ol><li><strong>Purpose</strong>: To deploy additional functionality alongside a microservice.</li><li><strong>Description</strong>: The sidecar pattern involves running a secondary process (sidecar) alongside the main microservice to handle concerns like monitoring, logging, security, or service discovery. The sidecar usually runs in the same environment (e.g., same container or virtual machine) as the primary microservice.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Handling non-core responsibilities such as security, observability, or proxying.</li><li>Extending microservices without modifying their core functionality.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Overhead of managing sidecars.</li><li>Coordination between the sidecar and the microservice.</li></ul><h3>12. Proxy Pattern</h3><ol><li><strong>Purpose</strong>: To act as an intermediary that controls access to a service.</li><li><strong>Description</strong>: A proxy sits between clients and microservices to control access, load balancing, request routing, or logging. It could be used in combination with other patterns like the API Gateway.</li><li><strong>Use Cases</strong>:</li></ol><ul><li>Load balancing, security filtering, and rate-limiting for microservices.</li><li>Simplifying client-side interactions with backend services.</li></ul><p><strong>4. Challenges</strong>:</p><ul><li>Added complexity and potential bottlenecks in the proxy layer.</li><li>Single points of failure unless handled carefully.</li></ul><h3>Conclusion</h3><p>Microservices architecture introduces a set of unique challenges related to service communication, data consistency, transaction management, and system reliability. To address these challenges effectively, applying the right design patterns can significantly enhance the performance, maintainability, and scalability of the system. Choosing the appropriate patterns often depends on the business requirements, the level of service interdependence, and the underlying infrastructure.</p><p><em>That’s all for this article. Hope you liked it.</em></p><p>You Can Follow <a href="https://medium.com/@shubhijain"><strong>Shubhi</strong></a> For More Such Content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d978303c343" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Google Interview Experince — L5]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@shubhijain/my-google-interview-experince-l5-e5853499ced8?source=rss-964e7192f737------2"><img src="https://cdn-images-1.medium.com/max/900/1*eidLxgPwWuuSABrlpDm2pg.gif" width="900"></a></p><p class="medium-feed-snippet">Google is the dream company for almost every software engineer. Every Software Engineer wants to be a part of Google atleast once in their&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@shubhijain/my-google-interview-experince-l5-e5853499ced8?source=rss-964e7192f737------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@shubhijain/my-google-interview-experince-l5-e5853499ced8?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5853499ced8</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[l5]]></category>
            <category><![CDATA[interview-experience]]></category>
            <category><![CDATA[senior-software-engineer]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Thu, 12 Sep 2024 05:19:48 GMT</pubDate>
            <atom:updated>2026-07-05T09:16:45.322Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Israeli Queue — Flexible Data Structure]]></title>
            <link>https://medium.com/@shubhijain/israeli-queue-flexible-data-structure-0852cc2e5d1c?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/0852cc2e5d1c</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[israeli]]></category>
            <category><![CDATA[queue]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Wed, 07 Aug 2024 17:55:34 GMT</pubDate>
            <atom:updated>2024-08-07T17:55:34.935Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Israeli Queue — Flexible </strong>Data Structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*zLqRod3NHgxmtTmZ67Y7Vg.gif" /><figcaption>Queue</figcaption></figure><p>An <strong>Israeli Queue</strong> is a queue data structure with an interesting twist — it allows for the insertion of elements not just at the end, but potentially closer to the front under certain conditions, while still maintaining some level of fairness. This structure is inspired by real-life social behavior in queues in Israel, where people might allow friends or acquaintances to “cut” into the line ahead of them.</p><h3>Key Features of Israeli Queue</h3><ol><li><strong>Friendship Groups</strong>: Elements in the queue can belong to the same “friendship group.” When an element from the same group arrives, it can join the queue not necessarily at the end but closer to its friends.</li><li><strong>Priority</strong>: It balances fairness (like a standard queue) with the ability to accommodate priority for certain elements based on their grouping.</li><li><strong>Dynamic Structure</strong>: Unlike a strict FIFO (First-In, First-Out) queue, the position of a new element is influenced by its relationship to existing elements in the queue.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*6UshywjnIlO-9utguRGhrA.png" /><figcaption>Israeli Queue</figcaption></figure><h3>Use Cases:</h3><ul><li><strong>Real-life queuing scenarios</strong>: Modeling human behavior in queues where people might allow acquaintances to join them.</li><li><strong>Task Scheduling</strong>: Systems where tasks or processes are prioritized based on group affiliation, but fairness is still a consideration.</li><li><strong>Networking</strong>: Situations where packets from the same flow (friendship group) might be allowed to be reordered for efficiency.</li></ul><h3>Implementation:</h3><p>The implementation of an Israeli Queue can vary, but it generally involves:</p><ol><li>Maintaining a regular queue structure.</li><li>Tracking groups and their positions within the queue.</li><li>Deciding the insertion point of a new element based on its group affiliation.</li></ol><p>This structure can be implemented using linked lists, arrays with additional metadata, or more advanced structures like heaps, depending on the performance requirements.</p><p>Let’s take an example to deep dive into its implementation. Here we will be using a singly linked list to maintain the queue and a HashMap to keep track of the positions of the last nodes for each group.</p><pre>import java.util.HashMap;<br><br>class Node {<br>    String value;<br>    String group;<br>    Node next;<br><br>    public Node(String value, String group) {<br>        this.value = value;<br>        this.group = group;<br>        this.next = null;<br>    }<br>}<br><br>class IsraeliQueue {<br>    private Node head;<br>    private Node tail;<br>    private HashMap&lt;String, Node&gt; groupPositions;<br><br>    public IsraeliQueue() {<br>        this.head = null;<br>        this.tail = null;<br>        this.groupPositions = new HashMap&lt;&gt;();<br>    }<br><br>    public void enqueue(String value, String group) {<br>        Node newNode = new Node(value, group);<br><br>        if (head == null) {<br>            // Queue is empty, insert the first element<br>            head = tail = newNode;<br>        } else {<br>            if (groupPositions.containsKey(group)) {<br>                // Insert after the last node of the same group<br>                Node lastGroupNode = groupPositions.get(group);<br>                newNode.next = lastGroupNode.next;<br>                lastGroupNode.next = newNode;<br><br>                if (lastGroupNode == tail) {<br>                    tail = newNode;<br>                }<br>            } else {<br>                // Insert at the end of the queue<br>                tail.next = newNode;<br>                tail = newNode;<br>            }<br>        }<br><br>        // Update the group&#39;s last node position<br>        groupPositions.put(group, newNode);<br>    }<br><br>    public String dequeue() {<br>        if (head == null) {<br>            throw new IllegalStateException(&quot;Dequeue from empty queue&quot;);<br>        }<br><br>        String value = head.value;<br>        String group = head.group;<br>        head = head.next;<br><br>        if (head == null || !head.group.equals(group)) {<br>            groupPositions.remove(group);<br>        }<br><br>        return value;<br>    }<br><br>    public String peek() {<br>        if (head == null) {<br>            throw new IllegalStateException(&quot;Peek from empty queue&quot;);<br>        }<br>        return head.value;<br>    }<br><br>    public boolean isEmpty() {<br>        return head == null;<br>    }<br><br>    public void display() {<br>        Node current = head;<br>        while (current != null) {<br>            System.out.println(&quot;Value: &quot; + current.value + &quot;, Group: &quot; + current.group);<br>            current = current.next;<br>        }<br>    }<br><br>    public static void main(String[] args) {<br>        IsraeliQueue queue = new IsraeliQueue();<br>        queue.enqueue(&quot;Task 1&quot;, &quot;Group A&quot;);<br>        queue.enqueue(&quot;Task 2&quot;, &quot;Group B&quot;);<br>        queue.enqueue(&quot;Task 3&quot;, &quot;Group A&quot;);<br>        queue.enqueue(&quot;Task 4&quot;, &quot;Group C&quot;);<br>        queue.enqueue(&quot;Task 5&quot;, &quot;Group B&quot;);<br><br>        System.out.println(&quot;Queue after enqueues:&quot;);<br>        queue.display();<br><br>        System.out.println(&quot;\nDequeued: &quot; + queue.dequeue());<br>        System.out.println(&quot;Queue after dequeue:&quot;);<br>        queue.display();<br>    }<br>}</pre><h4>Output</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*noZV2yQxOA0e2Ka_RGSHFg.png" /></figure><h3>Conclusion</h3><p>The Israeli Queue provides us a balanced approach to managing priorities and fairness, making it valuable in systems where group relationships and order of processing are important.</p><p><em>That’s all for this article. Hope you liked it.</em></p><p>You Can Follow <a href="https://medium.com/@shubhijain"><strong>Shubhi</strong></a> For More Such Content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0852cc2e5d1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1105. Filling Bookcase Shelves || Leetcode]]></title>
            <link>https://medium.com/@shubhijain/1105-filling-bookcase-shelves-e8fe86ed21a3?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8fe86ed21a3</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[daily-questions]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Wed, 31 Jul 2024 14:10:02 GMT</pubDate>
            <atom:updated>2024-08-01T05:25:14.069Z</atom:updated>
            <content:encoded><![CDATA[<p>You are given an array books where books[i] = [thicknessi, heighti] indicates the thickness and height of the ith book. You are also given an integer shelfWidth.</p><p>We want to place these books in order onto bookcase shelves that have a total width shelfWidth.</p><p>We choose some of the books to place on this shelf such that the sum of their thickness is less than or equal to shelfWidth, then build another level of the shelf of the bookcase so that the total height of the bookcase has increased by the maximum height of the books we just put down. We repeat this process until there are no more books to place.</p><p>Note that at each step of the above process, the order of the books we place is the same order as the given sequence of books.</p><ul><li>For example, if we have an ordered list of 5 books, we might place the first and second book onto the first shelf, the third book on the second shelf, and the fourth and fifth book on the last shelf.</li></ul><p>Return <em>the minimum possible height that the total bookshelf can be after placing shelves in this manner</em>.</p><p><strong>Example 1:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/0*pBFSF_2t2dHqZ_V-.png" /></figure><pre>Input: books = [[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelfWidth = 4<br>Output: 6<br>Explanation:<br>The sum of the heights of the 3 shelves is 1 + 3 + 2 = 6.<br>Notice that book number 2 does not have to be on the first shelf.</pre><p><strong>Example 2:</strong></p><pre>Input: books = [[1,3],[2,4],[3,2]], shelfWidth = 6<br>Output: 4</pre><h4>Algorithm</h4><p>Since in this question, we have to place the books in-order in shelves. That means, in a shelf the books are continues books from input list given.</p><p>Intuition here is to check for all the possibilites for ith book to be placed and get the minimum height of bookcase. So, we need to do recursion here, and storing the minimum height of bookcase till ith book in dp[i+1].</p><ol><li>Initialize <em>dp</em> array of size <em>books.length+1</em>. <em>dp[i]</em> represents the minimum height of the bookshelf when containing all books up to and excluding book <em>i</em>.</li><li>Set base cases: <em>dp[0]</em> is 0 (height of an empty bookcase).</li><li>Iterate from <em>i=1</em> to <em>books.length</em></li><li>Initialize <em>height </em>to the height of the current book.</li><li>Initialize <em>width</em> to the width of the current book.</li><li>Set <em>dp[i] </em>to the height of the current book (<em>height</em>) plus the height of the bookcase containing all previous books (<em>dp[i-1]</em>).</li><li>Iterate backward from <em>j = i - 1 </em>till<em> j &gt; 0 and width + books[j — 1][0] &lt;= shelf_width</em></li><li>Set <em>height </em>to maximum of <em>height</em> and <em>j-1th books height</em>.</li><li>Add <em>width of (j-1)th book</em> to current <em>width</em>.</li><li>Update <em>dp[i] </em>to the minimum of current <em>dp[i] and height + dp[j-1].</em></li><li>Decrease <em>j</em> by <em>1. </em>And start from 8th step till the if conditions match<em>.</em></li><li>Return dp[books.length].</li></ol><h4>Code</h4><pre>class Solution {<br>    public int minHeightShelves(int[][] books, int shelf_width) {<br>        int n = books.length;<br>        int[] dp = new int[n+1];<br><br>        for (int i = 1; i &lt;= n; i++) {<br>            int height = books[i - 1][1];<br>            int width = books[i - 1][0];<br>            dp[i] = dp[i - 1] + height;<br>            <br>            for (int j = i - 1; j &gt; 0 &amp;&amp; width + books[j - 1][0] &lt;= shelf_width; j--) {<br>                height = Math.max(height, books[j - 1][1]);<br>                width += books[j - 1][0];<br>                dp[i] = Math.min(dp[i], height + dp[j - 1]);<br>            }<br>        }<br>        return dp[n];<br>    }<br>}</pre><h4>Time Complexity</h4><p><strong>O(N*W)</strong></p><h4>Space Complexity</h4><p>O(N+1)~<strong>O(N)</strong></p><p><em>That’s all for this article. Hope you liked it.</em></p><p>You Can Follow <a href="https://medium.com/@shubhijain"><strong>Shubhi</strong></a> For More Such Content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8fe86ed21a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strobogrammatic Number II || Leetcode]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Given an integer n, return all the strobogrammatic numbers that are of length n. You may return the answer in any order.</p><p class="medium-feed-link"><a href="https://medium.com/@shubhijain/strobogrammatic-number-ii-7caf0392a305?source=rss-964e7192f737------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@shubhijain/strobogrammatic-number-ii-7caf0392a305?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/7caf0392a305</guid>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Sat, 27 Jul 2024 18:16:36 GMT</pubDate>
            <atom:updated>2024-08-01T05:25:34.052Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Top 11 Approaches to solve DSA Problems]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://interviewnoodle.com/top-11-approaches-to-solve-dsa-problems-41bcab2a6549?source=rss-964e7192f737------2"><img src="https://cdn-images-1.medium.com/max/921/1*sF7juZuiumjZ6d6AebDUdg.png" width="921"></a></p><p class="medium-feed-snippet">In interviews of almost every company when questions are asked specifically in IT Companies&#xA0;, they want to analyse your problem solving&#x2026;</p><p class="medium-feed-link"><a href="https://interviewnoodle.com/top-11-approaches-to-solve-dsa-problems-41bcab2a6549?source=rss-964e7192f737------2">Continue reading on InterviewNoodle »</a></p></div>]]></description>
            <link>https://interviewnoodle.com/top-11-approaches-to-solve-dsa-problems-41bcab2a6549?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/41bcab2a6549</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dsa-training]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[greedy-algorithms]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Thu, 25 Jul 2024 19:27:40 GMT</pubDate>
            <atom:updated>2024-08-08T13:52:34.275Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Strobogrammatic Number || Leetcode]]></title>
            <link>https://medium.com/@shubhijain/strobogrammatic-number-a45368f82da0?source=rss-964e7192f737------2</link>
            <guid isPermaLink="false">https://medium.com/p/a45368f82da0</guid>
            <category><![CDATA[numbers]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[string]]></category>
            <dc:creator><![CDATA[Shubhi Jain]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 05:30:31 GMT</pubDate>
            <atom:updated>2024-08-01T05:25:39.707Z</atom:updated>
            <content:encoded><![CDATA[<p>Given a string <strong>num </strong>which represents an integer, return <strong>true </strong><em>if </em><strong><em>num </em></strong><em>is a </em><strong><em>strobogrammatic number</em></strong>. A <strong>strobogrammatic number</strong> is a number that looks the same when rotated 180 degrees (looked at upside down).</p><pre>Example 1:<br>Input: num = &quot;69&quot;<br>Output: true<br>Example 2:<br>Input: num = &quot;88&quot;<br>Output: true<br>Example 3:<br>Input: num = &quot;962&quot;<br>Output: false<br></pre><h3>Algorithm</h3><ol><li>Create a map of 0 to 9 with value as there <strong>strobogrammatic </strong>part</li><li>Now take 2 pointers l and r</li><li>As there must be the <strong>strobogrammatic </strong>part of lth character at rth index</li><li>If <strong>strobogrammatic </strong>part of lth character at rth index is not present, or the lth character is itself doesn&#39;t map any value in map, then return false</li><li>Else traverse till l and r become equal</li></ol><pre>public boolean isStrobogrammatic(String num) {<br>    Map&lt;Character, Character&gt; map = new HashMap&lt;Character, Character&gt;();<br>    map.put(&#39;6&#39;, &#39;9&#39;);<br>    map.put(&#39;9&#39;, &#39;6&#39;);<br>    map.put(&#39;0&#39;, &#39;0&#39;);<br>    map.put(&#39;1&#39;, &#39;1&#39;);<br>    map.put(&#39;8&#39;, &#39;8&#39;);<br>   <br>    int l = 0, r = num.length() - 1;<br>    while (l &lt;= r) {<br>        if (!map.containsKey(num.charAt(l))) return false;<br>        if (map.get(num.charAt(l)) != num.charAt(r))<br>            return false;<br>        l++;<br>        r--;<br>    }<br>    <br>    return true;<br>}</pre><blockquote><em>Time Complexity : O(N)</em></blockquote><blockquote><em>Space Complexity : O(1)</em></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0miM9ZzpwoA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0miM9ZzpwoA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0miM9ZzpwoA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/30ccecc4898a79f4280599ece65bed67/href">https://medium.com/media/30ccecc4898a79f4280599ece65bed67/href</a></iframe><p><em>That’s all for this article. Hope you liked it.</em></p><p>You Can Follow <a href="https://medium.com/@shubhijain"><strong>Shubhi</strong></a> For More Such Content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a45368f82da0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>