<?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 Santosh Kumar Mishra on Medium]]></title>
        <description><![CDATA[Stories by Santosh Kumar Mishra on Medium]]></description>
        <link>https://medium.com/@iamsantoshmishra?source=rss-72e30f05d5aa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Tu4q9UIUgiufj5ADtDUiUQ.jpeg</url>
            <title>Stories by Santosh Kumar Mishra on Medium</title>
            <link>https://medium.com/@iamsantoshmishra?source=rss-72e30f05d5aa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 22:49:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iamsantoshmishra/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[SD 02: Functional vs Non-Functional Requirements: What You Must Know Before Building Any System]]></title>
            <link>https://medium.com/interviewcafe/sd-02-functional-vs-non-functional-requirements-what-you-must-know-before-building-any-system-f1c4b156eb7e?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1c4b156eb7e</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[faang-interview]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Wed, 14 May 2025 20:28:15 GMT</pubDate>
            <atom:updated>2025-05-14T20:28:15.501Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><h3>Why Requirements Matter in System Design</h3><p>Imagine building a house without asking the owner how many bedrooms they want or whether they need a garage.</p><p><strong>Sounds ridiculous, right?</strong></p><p>But that’s exactly what happens when software teams jump into coding without clarifying <strong>what the system should do</strong> and <strong>how it should perform</strong>.</p><p>In the world of system design, requirements are your <strong>foundation</strong>.</p><p>They define the expectations of a system from both a business and technical perspective. Without them, you’re building in the dark.</p><ul><li><strong>Functional requirements</strong> tell you what the system should do — logins, payments, notifications.</li><li><strong>Non-functional requirements (NFRs)</strong> define how the system should behave — fast response times, security, uptime, scalability.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jc3NGah3PBrqtu21.png" /></figure><p>Clear requirements eliminate ambiguity, reduce rework, and ensure all stakeholders — engineers, designers, product managers, and clients — are on the same page.</p><p>When defined and documented properly, they guide every decision in the software development lifecycle (SDLC).</p><blockquote><strong><em>Crack Java Interviews Like a Pro</em></strong><em> with my new Book — “The Art of Cracking Java Interviews”</em></blockquote><blockquote><a href="https://topmate.io/iamsantoshmishra/1490067?coupon_code=CRACKJAVA25"><em>Grab your copy now &amp; step up your prep!</em></a></blockquote><h3>Common Mistakes Developers Make Without Clear Requirements</h3><p>Developers often focus on features, ignoring how those features should behave under pressure.</p><p><strong>Here’s what happens when teams skip proper requirements gathering:</strong></p><ul><li><strong>Performance issues:</strong> The app works but crashes under load.</li><li><strong>Security vulnerabilities:</strong> Login works but isn’t protected against brute-force attacks.</li><li><strong>Scalability nightmares:</strong> Everything works until you hit 10,000 users — then it collapses.</li></ul><blockquote><strong>Point to remember:</strong> A great feature is useless if it’s not usable, secure, or fast. Requirements help you avoid building a “<strong>functionally correct but practically unusable</strong>” system.</blockquote><h3>What Are Functional Requirements?</h3><h3>Definition and Purpose</h3><p>Functional requirements define the <strong>core functionality</strong> of a system.</p><p>They describe what the system should do, from a <strong>user’s perspective</strong>.</p><p>If someone asks, “<strong>What features will the system provide?</strong>” — they’re asking about functional requirements.</p><p>These are the <strong>tasks</strong>, <strong>operations</strong>, and <strong>behaviors</strong> your system must support.</p><p><strong>For example:</strong></p><ul><li>“The system shall allow users to register an account.”</li><li>“The system shall send an email confirmation upon registration.”</li></ul><p><strong>In technical terms, functional requirements focus on:</strong></p><ul><li>Input → Processing → Output</li><li>Data management (CRUD operations)</li><li>Business rules and workflows</li></ul><h3>Real-Life Examples</h3><p>Let’s bring this to life with a simple app — say, <strong>a food delivery application</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*91wGkmfg7kqBLxR1.png" /></figure><blockquote>Each of these functionalities defines <strong>what</strong> the system must do to fulfil its business purpose.</blockquote><h3>How to Identify Functional Requirements in Projects</h3><ol><li><strong>Talk to users and stakeholders:</strong> What do they want the system to do?</li><li><strong>Review current processes:</strong> If replacing an old system, what functions must be replicated?</li><li><strong>Use diagrams:</strong> Flowcharts, use case diagrams, and user stories help uncover key operations.</li></ol><blockquote><strong><em>Tip:</em></strong><em> Use the “</em><strong><em>Given-When-Then</em></strong><em>” format to write behavior-driven requirements:</em></blockquote><blockquote><em>Given a registered user, when they add an item to the cart, then the cart should update with the item and price.</em></blockquote><h3>What Are Non-Functional Requirements?</h3><h3>Definition and Importance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mPwG6M-4bpmSIUB0.png" /></figure><p>While functional requirements define what the system does, <strong>non-functional requirements (NFRs)</strong> define <strong>how</strong> the system performs.</p><p>Think of these as the <strong>quality attributes</strong> of your system.</p><ul><li>How fast should the system respond?</li><li>How many users should it support?</li><li>How secure must it be?</li><li>How easy should it be to use?</li></ul><p>These don’t add features but <strong>enhance usability, performance, and reliability</strong>. Without them, a system may “<strong>work</strong>,” but still fail in the real world.</p><h3>Real-Life Examples</h3><p>Let’s go back to our food delivery app.</p><p><strong>Here are some non-functional requirements:</strong></p><ul><li><strong>Performance:</strong> The app must load within 2 seconds.</li><li><strong>Availability:</strong> The system must be available 99.9% of the time.</li><li><strong>Scalability:</strong> Must support 10,000 concurrent users during peak hours.</li><li><strong>Security:</strong> All user data must be encrypted in transit and at rest.</li><li><strong>Usability:</strong> The UI must be mobile-responsive and accessible.</li></ul><h3>Common Categories of Non-Functional Requirements</h3><ol><li><strong>Performance Requirements:</strong> Response time, throughput, latency.</li><li><strong>Scalability:</strong> Horizontal/vertical scaling capability.</li><li><strong>Security:</strong> Authentication, authorization, data encryption.</li><li><strong>Reliability:</strong> System should operate correctly over time.</li><li><strong>Maintainability:</strong> Easy to update, debug, and patch.</li><li><strong>Portability:</strong> Can the app run across platforms or devices?</li><li><strong>Compliance:</strong> GDPR, HIPAA, PCI DSS requirements.</li></ol><blockquote><strong><em>Quick Note: </em></strong><em>NFRs often become system-wide decisions, impacting your architecture, choice of technologies, and deployment strategies.</em></blockquote><h3>Functional vs. Non-Functional Requirements: The Key Differences</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*6L5b55pvqvP_RPGA.png" /></figure><h3>Practical Differences in Implementation</h3><p>Functional requirements often translate to <strong>feature development</strong>, while non-functional requirements often require:</p><ul><li>Architectural design changes (e.g., adding caching for speed)</li><li>Infrastructure setup (e.g., load balancers for scalability)</li><li>DevOps configurations (e.g., monitoring and alerting tools)</li></ul><h3>How These Influence System Design Decisions</h3><p>If you’re designing a <strong>banking system</strong>, security and data integrity (non-functional) will shape every functional design — right from login mechanisms to data storage choices.</p><p>If you’re building a <strong>real-time messaging app</strong>, latency and throughput requirements could influence your decision to use <strong>WebSockets</strong> instead of traditional HTTP polling.</p><blockquote><strong>Point to remember:</strong> Ignoring non-functional requirements in design is like building a sports car with no brakes — it might be fast, but it’s dangerous.</blockquote><h3>Gathering and Documenting Requirements</h3><h3>Stakeholder Interviews</h3><p>The first and most crucial step in gathering requirements is <strong>talking to the right people</strong>. Stakeholders include everyone who has a vested interest in the system — product managers, end-users, business executives, developers, QA teams, and sometimes even regulators.</p><p><strong>Why interviews matter:</strong></p><ul><li>They surface expectations, pain points, and goals.</li><li>They help discover both <strong>explicit</strong> and <strong>implicit</strong> needs.</li><li>They ensure you’re building what the business actually needs — not just what seems logical on paper.</li></ul><p><strong>Sample questions to ask stakeholders:</strong></p><ul><li>What problem are we trying to solve?</li><li>Who will use this system and how?</li><li>What are the most critical operations?</li><li>What could make or break this system for you?</li></ul><p>By conducting these interviews, you often uncover functional requirements (“I want to log in via Google”) and non-functional ones (“It should work even with slow mobile internet”).</p><blockquote><strong><em>Tip:</em></strong><em> Always confirm your understanding with written summaries or mock-ups to avoid misinterpretation.</em></blockquote><h3>Using Use Cases and User Stories</h3><p>Once you’ve gathered enough insights, structure them using <strong>use cases</strong> and <strong>user stories</strong>.</p><ul><li><strong>Use Case:</strong> Describes how a user interacts with a system to achieve a goal. It’s scenario-based.</li><li><strong>User Story:</strong> A brief, informal description written from the end-user’s point of view.</li></ul><p><strong>Example:</strong></p><ul><li><strong>Use Case:</strong> “A customer adds items to the cart and completes checkout using a credit card.”</li><li><strong>User Story:</strong> “As a customer, I want to add items to my cart so I can purchase multiple products at once.”</li></ul><p><strong>Benefits:</strong></p><ul><li>Keeps requirements user-centric</li><li>Helps developers prioritize what to build</li><li>Ensures traceability throughout the project</li></ul><blockquote><strong>Point to Remember:</strong> User stories should include acceptance criteria to clarify when the story is “<strong>done</strong>.”</blockquote><h3>Tools and Best Practices for Documentation</h3><p>Documentation doesn’t need to be a pain. Use the right tools and best practices to keep it efficient and collaborative:</p><p><strong>Tools:</strong></p><ul><li><strong>Jira + Confluence</strong> for agile teams</li><li><strong>Trello or Notion</strong> for lightweight needs</li><li><strong>Lucidchart or </strong><a href="http://draw.io/"><strong>Draw.io</strong></a> for flow diagrams</li></ul><p><strong>Best Practices:</strong></p><ul><li>Version control your documentation</li><li>Use clear, jargon-free language</li><li>Group requirements by priority and component</li><li>Keep a change log to track updates over time</li></ul><blockquote><strong><em>Pro Tip:</em></strong><em> Always link functional requirements to their corresponding non-functional requirements.</em></blockquote><blockquote><em>For example, a “</em><strong>Login feature</strong><em>” might require “</em><strong>2-second response time under load.</strong><em>”</em></blockquote><h3>Prioritizing Requirements in System Design</h3><h3>MoSCoW Technique (Must Have, Should Have, Could Have, Won’t Have)</h3><p>Not all requirements are created equal. Some are essential, others are nice to have.</p><p>The <strong>MoSCoW method</strong> helps in setting priorities:</p><ul><li><strong>Must Have</strong>: System won’t function without it. (e.g., User authentication)</li><li><strong>Should Have</strong>: Important but not vital. (e.g., Social login support)</li><li><strong>Could Have</strong>: Adds value but optional. (e.g., Animated transitions)</li><li><strong>Won’t Have (for now)</strong>: Out of scope for the current release. (e.g., Dark mode)</li></ul><p><strong>Why it’s useful:</strong></p><ul><li>Keeps teams focused on what’s critical</li><li>Helps manage stakeholder expectations</li><li>Supports phased delivery in agile development</li></ul><h3>Balancing Business Needs vs. Technical Constraints</h3><p>Sometimes, business wants a feature that’s technically complex, or performance expectations that require significant infrastructure investment.</p><p>This is where <strong>trade-off discussions</strong> happen.</p><p><strong>You need to balance:</strong></p><ul><li><strong>Business value</strong> vs. <strong>Implementation cost</strong></li><li><strong>User experience</strong> vs. <strong>Technical feasibility</strong></li><li><strong>Speed to market</strong> vs. <strong>Long-term scalability</strong></li></ul><blockquote><strong><em>Example:</em></strong><em> Business might want real-time chat in version 1, but it might be more efficient to start with asynchronous messaging and add real-time features later.</em></blockquote><blockquote><strong><em>Tip:</em></strong><em> Use architectural spikes and proof-of-concepts to assess feasibility before committing to complex requirements.</em></blockquote><h3>Creating a Requirements Traceability Matrix</h3><p>A <strong>Requirements Traceability Matrix (RTM)</strong> helps map each requirement to its:</p><ul><li>Business goal</li><li>Related user story</li><li>Design component</li><li>Test case</li></ul><p><strong>Why it’s valuable:</strong></p><ul><li>Ensures no requirement gets lost in translation</li><li>Tracks the status of each requirement through the SDLC</li><li>Helps during audits, compliance checks, and client demos</li></ul><p><strong>Sample RTM Entry:</strong></p><p>Requirement ID Description Related User Story Module Test Case Status FR-101 Users must be able to reset password As a user, I want to reset my password Auth Service TC-101 In Progress</p><blockquote><strong><em>Quick Note:</em></strong><em> RTMs are especially useful in large, regulated projects like finance, healthcare, and aerospace.</em></blockquote><h3>Real-World Case Studies</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d7gMlHtRSjR_poAi.png" /></figure><h3>E-commerce Platform</h3><p><strong>Functional Requirements:</strong></p><ul><li>Browse products, add to cart, apply discount codes, place orders</li><li>View order history, track shipment, process returns</li></ul><p><strong>Non-Functional Requirements:</strong></p><ul><li>Must support 1,000 concurrent users</li><li>Payment transactions should complete within 3 seconds</li><li>99.95% uptime expected during seasonal sales</li></ul><p><strong>Design Impact:</strong></p><ul><li>Used horizontal scaling, CDN caching for images, and failover servers</li><li>Integrated a payment gateway with a fallback option for reliability</li></ul><blockquote><strong><em>Lesson Learned:</em></strong><em> Functional features bring users in, but non-functional attributes keep them loyal.</em></blockquote><h3>Banking System</h3><p><strong>Functional Requirements:</strong></p><ul><li>View account balance, transfer money, generate statements</li><li>Two-factor authentication for logins</li></ul><p><strong>Non-Functional Requirements:</strong></p><ul><li>Must comply with PCI-DSS</li><li>Data encryption (AES-256), audit trails, 24/7 availability</li><li>Recovery point objective (RPO) of 1 minute</li></ul><p><strong>Design Impact:</strong></p><ul><li>Architected for zero-trust, included tokenization for sensitive data</li><li>Used distributed databases with real-time replication</li></ul><blockquote><strong>Lesson Learned:</strong> Security and compliance are not optional — they’re integral.</blockquote><h3>Social Media App</h3><p><strong>Functional Requirements:</strong></p><ul><li>Post images, follow users, comment, like</li><li>Receive notifications and messages</li></ul><p><strong>Non-Functional Requirements:</strong></p><ul><li>Infinite scroll should load within 2 seconds</li><li>App must handle 50K users simultaneously</li><li>Notifications must be delivered in real-time</li></ul><p><strong>Design Impact:</strong></p><ul><li>Used Kafka for real-time updates and Redis for caching</li><li>Applied content delivery networks (CDNs) for media files</li></ul><blockquote><strong><em>Lesson Learned:</em></strong><em> For user engagement, performance and UX are just as important as core features.</em></blockquote><h3>Impact of Ignoring Non-Functional Requirements</h3><h3>Real-Life Failures and Lessons Learned</h3><ol><li><a href="http://healthcare.gov/"><strong>Healthcare.gov</strong></a><strong> Launch (2013)</strong>: The site crashed repeatedly due to an inability to handle unexpected user traffic — lack of scalability planning (an NFR).</li><li><strong>Slack Outage (2022)</strong>: A downtime caused by a deployment bug magnified due to the absence of robust failover — an oversight in availability and resilience planning.</li><li><strong>T-Mobile Data Breach</strong>: Poor encryption and security measures led to the leakage of customer data — a failure to prioritize non-functional security requirements.</li></ol><blockquote><strong>Key Takeaway:</strong> You can’t “patch” a bad design with a bug fix. Ignoring non-functional requirements early results in <strong>catastrophic rework</strong> later.</blockquote><h3>Performance Bottlenecks</h3><p>Without clear performance benchmarks:</p><ul><li>Your database might become the bottleneck.</li><li>The system may time out under traffic spikes.</li><li>APIs may take too long to respond, frustrating users.</li></ul><blockquote><strong><em>Tip:</em></strong><em> Use load testing tools (like JMeter or Locust) based on your NFRs to test system health before release.</em></blockquote><h3>Security Breaches Due to Overlooked NFRs</h3><p>It’s not enough that the login feature works. If it:</p><ul><li>Stores passwords in plain text</li><li>Allows unlimited login attempts</li><li>Lacks multi-factor authentication</li></ul><p>…you’re inviting disaster.</p><blockquote><strong><em>Best Practice:</em></strong><em> Treat security requirements as </em><strong><em>non-negotiable</em></strong><em> and design them into every component from day one.</em></blockquote><h3>Tools to Capture and Manage Requirements</h3><h3>Jira, Confluence, and Trello</h3><p>Agile development thrives on fast-paced iteration and collaboration — and these tools are the champions of agile project management.</p><ul><li><strong>Jira</strong>: Ideal for logging user stories, sprints, and linking development tasks with requirements. You can even categorize stories into functional and non-functional types.</li><li><strong>Confluence</strong>: Perfect for writing detailed documentation and requirement specifications. Teams often link Confluence pages with Jira tickets for traceability.</li><li><strong>Trello</strong>: Simpler and more visual — great for early-stage planning or non-technical stakeholders.</li></ul><p><strong>Why they work well:</strong></p><ul><li>Easy collaboration</li><li>Centralized documentation</li><li>Version tracking</li><li>Custom workflows for approvals</li></ul><blockquote><strong><em>Pro Tip:</em></strong><em> Use templates in Confluence to standardize how functional and non-functional requirements are documented.</em></blockquote><h3>Requirement Management Tools (IBM DOORS, Jama)</h3><p>For enterprise-grade projects — especially in industries like <strong>automotive, aerospace, finance, and healthcare</strong> — you need heavyweight tools that provide full lifecycle traceability and compliance tracking.</p><ul><li><strong>IBM DOORS</strong>: Highly customizable, used for complex and safety-critical systems.</li><li><strong>Jama Software</strong>: Great for collaborative specification writing with built-in impact analysis and risk assessment.</li></ul><p><strong>Key Features:</strong></p><ul><li>Requirements baseline comparison</li><li>Visual traceability matrices</li><li>Audit trails for every change</li></ul><p>These tools ensure nothing falls through the cracks when <strong>hundreds or thousands of requirements</strong> are in play.</p><h3>Version Control for Requirement Changes</h3><p>Just like source code, requirements evolve. New features are requested, constraints shift, regulations change. That’s why tracking versions of requirements is crucial.</p><p><strong>Best Practices:</strong></p><ul><li>Use Git or integrated document versioning tools</li><li>Tag major releases or milestones</li><li>Maintain a changelog of updated or deprecated requirements</li></ul><blockquote><strong><em>Quick Note:</em></strong><em> A single change in a non-functional requirement (like a new SLA for uptime) can ripple across your entire architecture. Version control ensures you understand the impact.</em></blockquote><h3>Tips for Developers and Architects</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wcV1TR7LLcLdWxQs.png" /></figure><h3>Think Like a User First</h3><p>Before writing a single line of code or drawing an architecture diagram, ask yourself:</p><ul><li>“What would I expect this system to do?”</li><li>“How would I use this if I were the customer?”</li></ul><p>Empathy drives better systems. The more time you spend understanding the end-user, the more relevant your functional requirements become.</p><h3>Collaborate with Business Analysts</h3><p>Developers and architects shouldn’t work in silos. Collaborating with Business Analysts (BAs) brings two benefits:</p><ul><li>BAs understand the business goals and user expectations.</li><li>Engineers understand what’s technically possible and scalable.</li></ul><blockquote><strong><em>Pro Tip:</em></strong><em> Involve BAs in requirement reviews. Their perspective often highlights edge cases and overlooked NFRs (like accessibility or legal compliance).</em></blockquote><h3>Validate and Revisit Requirements Regularly</h3><p>Requirements aren’t “<strong>set and forget</strong>” They should evolve as your product, users, and market grow.</p><ul><li><strong>Hold requirement review sessions</strong> every sprint or release.</li><li><strong>Use feedback from QA and customer support</strong> to adjust or add requirements.</li><li><strong>Conduct A/B tests or user surveys</strong> to validate assumptions.</li></ul><blockquote><strong><em>Lesson:</em></strong><em> A requirement that made sense at the beginning of the project might be obsolete six months later. Stay agile.</em></blockquote><h3>Interview Tips Related to Requirements Gathering</h3><h3>Common Questions Asked in Interviews</h3><p>If you’re interviewing for a system design or architect role, expect these questions:</p><ul><li>How do you gather requirements for a new project?</li><li>Can you differentiate functional vs. non-functional requirements?</li><li>Give an example where ignoring NFRs led to problems.</li><li>How do you manage changing requirements mid-project?</li></ul><blockquote><strong><em>Bonus:</em></strong><em> In behavioral interviews, you’ll often be asked to walk through a real project and explain how you approached requirement analysis.</em></blockquote><h3>How to Structure Your Response</h3><p>Use the <strong>STAR Method</strong> (Situation, Task, Action, Result) to structure your answer.</p><p><strong>Example:</strong></p><ul><li><strong>S</strong>: “We were building a health tracking app…”</li><li><strong>T</strong>: “…and needed to define all the user and system requirements.”</li><li><strong>A</strong>: “I led stakeholder workshops, documented user stories in Jira, and collaborated with the QA team to derive performance metrics.”</li><li><strong>R</strong>: “We shipped on time, with &lt;1% production bugs and a 4.8 user rating.”</li></ul><h3>STAR Method for Scenario-Based Questions</h3><p>Here’s how to apply <strong>STAR</strong> in system design interviews:</p><ul><li><strong>Situation</strong>: Brief background</li><li><strong>Task</strong>: What were you responsible for?</li><li><strong>Action</strong>: What did you do specifically?</li><li><strong>Result</strong>: What was the measurable outcome?</li></ul><blockquote><strong><em>Interview Tip:</em></strong><em> Always mention </em><strong><em>tools used, techniques followed</em></strong><em>, and </em><strong><em>trade-offs considered</em></strong><em> — that’s what interviewers care about most.</em></blockquote><h3>Quick Notes and Summary Table</h3><h3>Bullet Points Recap</h3><ul><li>Functional requirements define <strong>what the system does</strong>.</li><li>Non-functional requirements define <strong>how the system performs</strong>.</li><li>NFRs are just as critical as features — ignoring them can cause system failures.</li><li>Use tools like <strong>Jira, Confluence, DOORS</strong>, and <strong>Trello</strong> for documentation.</li><li>Validate and update requirements often to keep pace with real-world changes.</li><li>Interviews test your <strong>understanding, communication</strong>, and <strong>analytical skills</strong> — be prepared.</li></ul><h3>Cheat Sheet for Developers</h3><p>Topic Functional Requirement Non-Functional Requirement Focus Business logic and features System performance, usability, security Examples Login, Checkout, Profile update Uptime, latency, encryption, scalability Tracked via User Stories, Use Cases KPIs, SLAs, monitoring tools Defined by Users, Product Managers Architects, DevOps, Compliance Officers Test method Unit and integration tests Load testing, security audits</p><h3>Conclusion</h3><p>In the rush to build and deploy software, it’s easy to get caught up in coding features and forget about how the system should behave in the real world. But building a product without clearly defined functional and non-functional requirements is like launching a rocket without a flight path.</p><p>Functional requirements give the product shape — what it can and should do. Non-functional requirements give it strength — how fast, how secure, how reliable. Together, they define not just a working system, but a successful one.</p><p>Whether you’re a junior developer, senior architect, or start-up founder, mastering the art of requirements gathering will save you time, money, and countless headaches down the road. It’s not a step in the process — it <strong>is</strong> the foundation of the process.</p><p>So next time you’re tempted to “<strong>just start building</strong>” stop.</p><p>Ask the right questions. Document the right answers. Design from requirements — and you’ll build better systems.</p><h3>FAQs</h3><h3>1. Can a requirement be both functional and non-functional?</h3><p>Generally, no. Functional requirements define what the system does, while non-functional requirements define how it behaves. However, some requirements may seem to overlap — like “The system must encrypt data during login” — which ties function with performance and security. In such cases, treat the “what” as functional and the “how” as non-functional.</p><h3>2. Who defines non-functional requirements in a team?</h3><p>Non-functional requirements are usually identified by system architects, DevOps engineers, product owners, and sometimes legal or compliance teams — depending on the system’s domain.</p><h3>3. How often should requirements be updated?</h3><p>Requirements should be reviewed at every major milestone — new releases, user feedback cycles, or when business goals shift. Agile teams typically revisit requirements during backlog grooming or sprint planning.</p><h3>4. What happens if requirements are incomplete?</h3><p>Incomplete requirements lead to <strong>scope creep</strong>, <strong>missed expectations</strong>, and <strong>expensive rework</strong>. Worse, it can cause system failures when unplanned use cases or traffic loads hit the system.</p><h3>5. Are non-functional requirements optional?</h3><p>Absolutely not. They are essential for real-world performance. A perfectly working feature that’s slow, insecure, or unreliable is as bad as a broken one.</p><blockquote><strong><em>Crack Java Interviews Like a Pro</em></strong><em> with my new Book — “The Art of Cracking Java Interviews”</em></blockquote><blockquote><a href="https://topmate.io/iamsantoshmishra/1490067?coupon_code=CRACKJAVA25"><em>Grab your copy now &amp; step up your prep!</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1c4b156eb7e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/interviewcafe/sd-02-functional-vs-non-functional-requirements-what-you-must-know-before-building-any-system-f1c4b156eb7e">SD 02: Functional vs Non-Functional Requirements: What You Must Know Before Building Any System</a> was originally published in <a href="https://medium.com/interviewcafe">InterviewCafe</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SD-01: Introduction to System Design]]></title>
            <link>https://medium.com/interviewcafe/sd-01-introduction-to-system-design-6f2a82f4adff?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f2a82f4adff</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[faang-interview]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[interview-prep]]></category>
            <category><![CDATA[system-design-series]]></category>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Thu, 01 May 2025 20:14:22 GMT</pubDate>
            <atom:updated>2025-05-01T20:17:18.913Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Introduction</h3><p>In today’s tech-driven world, system design is a crucial skill for software engineers, architects, and developers. It plays a significant role in creating scalable, efficient, and maintainable software systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*qmkeyxPiNNJ-3m0p.png" /></figure><p>Whether it’s a simple application or a large-scale distributed system like Facebook, Google, or Amazon, proper system design ensures the software meets performance, reliability, and scalability requirements.</p><p>Understanding system design is essential for tackling complex problems, optimizing resource usage, and ensuring seamless user experiences.</p><p>In this article, we will explore the fundamentals of system design, its importance, different types, and essential components, helping you gain a solid foundation in this critical field.</p><h3>2. What is System Design?</h3><p>System design is the process of defining the architecture, components, and data flow of a software system. It involves planning how different parts of a system interact with each other to meet functional and non-functional requirements.</p><p>At its core, system design helps developers build robust, scalable, and efficient systems by focusing on:</p><ul><li><strong>Structure</strong> — How components interact</li><li><strong>Scalability</strong> — Ensuring the system can handle growth</li><li><strong>Performance</strong> — Optimizing speed and efficiency</li><li><strong>Security</strong> — Protecting data and ensuring safe communication</li></ul><h3>3. Importance of System Design in Software Development</h3><p>Why should developers care about system design?</p><p>The answer lies in its ability to create scalable, efficient, and maintainable systems.</p><p>Here’s why system design is a crucial aspect of software development:</p><h3>1. Enhancing Scalability and Performance</h3><p>Modern applications must handle millions of users and massive amounts of data. Proper system design ensures that systems can scale horizontally (adding more machines) or vertically (upgrading existing hardware) while maintaining performance.</p><p><strong>Example</strong>: Social media platforms like Facebook use load balancers and distributed databases to handle billions of users without performance degradation.</p><h3>2. Reducing Complexity and Improving Maintainability</h3><p>A well-structured system is easier to understand, modify, and debug. Proper modularization, clear API design, and efficient data flow reduce complexity and make maintenance more manageable.</p><p><strong>Example</strong>: Microservices architecture divides large applications into smaller, independent services, making updates and troubleshooting simpler.</p><h3>3. Ensuring Reliability and Security</h3><p>System design also focuses on preventing failures and securing user data. Designing fault-tolerant systems ensures that even if a component fails, the overall system continues to function smoothly.</p><p><strong>Example</strong>: Cloud providers like AWS and Google Cloud implement redundant storage and failover mechanisms to prevent data loss.</p><h3>4. Types of System Design</h3><p>System design is categorized into two major types: high-level and low-level. Understanding both is essential for building effective software solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*75mFNXPV9JmudhW8.png" /></figure><h3>4.1 High-Level System Design (HLD)</h3><p>High-Level System Design provides a broad overview of the system architecture. It focuses on how various components interact and ensures that the system meets scalability, performance, and security goals.</p><h3>Key Aspects of HLD</h3><ul><li><strong>Architectural Patterns</strong> — Monolithic, Microservices, Event-driven, etc.</li><li><strong>Key Components</strong> — Databases, APIs, Load Balancers, Cache, Message Queues</li><li><strong>Deployment Strategies</strong> — Cloud-based, On-Premises, or Hybrid</li></ul><p><strong>Example:</strong></p><p>Consider designing a ride-sharing application like Uber. The high-level system design would define:</p><ul><li>User authentication and database storage</li><li>API interactions between users, drivers, and services</li><li>Load balancing and caching mechanisms for fast performance</li></ul><h3>4.2 Low-Level System Design (LLD)</h3><p>Low-Level System Design focuses on the finer details of individual components. It deals with class structures, algorithms, and data handling methods.</p><h3>Key Aspects of LLD</h3><ul><li><strong>Data Structures</strong> — HashMaps, Trees, Graphs, Queues</li><li><strong>Algorithms</strong> — Sorting, Searching, Load Distribution, Scheduling</li><li><strong>Class Diagrams</strong> — Relationships between objects and their behaviors</li></ul><p><strong>Example:</strong></p><p>For the same ride-sharing app, the LLD would include:</p><ul><li>How user authentication is implemented (e.g., OAuth, JWT tokens)</li><li>The data structure for tracking active rides</li><li>Algorithms for finding the nearest driver to a user</li></ul><h3>5. Key Components of System Design</h3><p>System design comprises multiple components, each playing a critical role in ensuring smooth operation. Below are the key components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*BGO3aNkb57qSbdHa.png" /></figure><h3>5.1 Client-Server Architecture</h3><ul><li>Defines how the client (frontend) communicates with the server (backend).</li><li>Includes REST APIs, GraphQL, and WebSockets for real-time communication.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*ZvvwjPzinsZy-ooi.png" /></figure><h3>5.2 Databases and Storage Systems</h3><ul><li><strong>SQL vs NoSQL</strong> — Choosing the right database for structured or unstructured data.</li><li><strong>Sharding &amp; Replication</strong> — Distributing data across multiple servers for better performance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*HcXQLkNJQZA9sX51.png" /></figure><h3>5.3 Networking and Communication</h3><ul><li><strong>Protocols</strong> — HTTP, HTTPS, TCP/IP, WebSockets</li><li><strong>CDN (Content Delivery Network)</strong> — Improves content delivery speed for global users.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*9jTnhv2kTAOJkIz7.png" /></figure><h3>5.4 Scalability and Load Balancing</h3><ul><li><strong>Horizontal Scaling</strong> — Adding more servers to distribute load.</li><li><strong>Vertical Scaling</strong> — Increasing resources on an existing server.</li><li><strong>Load Balancers</strong> — Distributing traffic to prevent overload on a single server.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*koNvF7QESgT_UPFZ.png" /></figure><h3>6 Architectural Patterns in System Design</h3><p>Different architectural patterns help in structuring software systems efficiently. Choosing the right pattern depends on scalability, maintainability, and performance needs.</p><h3>6.1 Monolithic Architecture</h3><ul><li>A single, unified codebase where all components are tightly integrated.</li><li>Pros: Simple deployment, easy debugging.</li><li>Cons: Difficult to scale, changes require redeploying the entire application.</li></ul><p><strong>Example</strong>: Traditional e-commerce websites built as a single application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*C8SNAJZJrKiYbBsa.png" /></figure><h3>6.2 Microservices Architecture</h3><ul><li>The application is divided into small, independent services that communicate via APIs.</li><li><strong>Pros</strong>: Scalable, easy to maintain, services can be deployed independently.</li><li><strong>Cons</strong>: More complex communication, potential latency issues.</li></ul><p><strong>Example</strong>: Netflix, Amazon, and Uber use microservices to handle different features separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*DYqoV-3lQTDYpD6k.png" /></figure><h3>6.3 Event-Driven Architecture</h3><ul><li>Components communicate by emitting and responding to events asynchronously.</li><li><strong>Pros</strong>: Highly scalable and loosely coupled.</li><li><strong>Cons</strong>: Debugging and tracing events can be complex.</li></ul><p><strong>Example</strong>: Real-time chat applications and IoT systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*4WD3gjlNDTq1CKXb.png" /></figure><h3>6.4 Serverless Architecture</h3><ul><li>Uses cloud services to run functions without managing infrastructure.</li><li>Pros: Cost-efficient, automatic scaling.</li><li>Cons: Limited customization, cold start latency.</li></ul><p><strong>Example</strong>: AWS Lambda for running event-driven functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*8UYRHisksnH78TZn.png" /></figure><h3>7. Database Management in System Design</h3><p>Databases are a critical part of system design. The choice depends on the data type, scalability, and access patterns.</p><h3>7.1 Relational Databases (SQL)</h3><ul><li>Uses structured tables and relationships (MySQL, PostgreSQL).</li><li>Ideal for applications requiring ACID compliance (banking systems).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*DZ8wIEGtvoRZtDJ8.png" /></figure><h3>7.2 NoSQL Databases</h3><ul><li>Includes document-based (MongoDB), key-value stores (Redis), column-based (Cassandra).</li><li>Ideal for applications with high scalability needs (social media, real-time analytics).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*eX6JZhEIj39vcUOU.png" /></figure><h3>7.3 Database Scaling Techniques</h3><ul><li><strong>Sharding</strong> — Splitting data across multiple servers.</li><li><strong>Replication</strong> — Creating copies of data for redundancy.</li><li><strong>Indexing</strong> — Optimizing search queries for faster access.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*HwUkL9Z1f-mQw8Ry.png" /></figure><h3>8. Caching Strategies for High-Performance Systems</h3><p>Caching helps reduce database load and improves system responsiveness.</p><h3>8.1 Types of Caching</h3><ul><li><strong>Application-level Caching</strong> — Storing frequently accessed data in memory (e.g., Memcached, Redis).</li><li><strong>Database Caching</strong> — Query results are cached to reduce redundant database calls.</li><li><strong>Content Delivery Network (CDN)</strong> — Distributes static content globally for fast access.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*2hVL1blQ8NCokVKI.png" /></figure><h3>8.2 Cache Invalidation Strategies</h3><ul><li><strong>Least Recently Used (LRU)</strong> — Removes old data when the cache is full.</li><li><strong>Write-through Cache</strong> — Writes data to both cache and database to ensure consistency.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*KBxePloEOt8QjZMR.png" /></figure><h3>9. Load Balancing Techniques</h3><p>Load balancing distributes traffic efficiently across multiple servers to ensure reliability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*985AJgKHJeRDIYsg.png" /></figure><h3>9.1 Types of Load Balancers</h3><ul><li><strong>Hardware Load Balancers</strong> — Expensive but provide high performance.</li><li><strong>Software Load Balancers</strong> — Cost-effective and flexible (Nginx, HAProxy).</li></ul><h3>9.2 Load Balancing Algorithms</h3><ul><li><strong>Round Robin</strong> — Sends requests sequentially to each server.</li><li><strong>Least Connections</strong> — Directs requests to the server with the fewest active connections.</li><li><strong>IP Hashing</strong> — Routes traffic based on the user’s IP address.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*orfEp_DCxFYnNza0.png" /></figure><h3>10. Security Considerations in System Design</h3><p>Security is essential to prevent vulnerabilities and cyber threats.</p><h3>10.1 Authentication &amp; Authorization</h3><ul><li><strong>OAuth &amp; JWT</strong> — Secure methods for user authentication.</li><li><strong>Role-based access control (RBAC)</strong> — Limits access based on user roles.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*0zrEJqy5bnkq_PTo.png" /></figure><h3>10.2 Encryption &amp; Data Protection</h3><ul><li><strong>TLS/SSL</strong> — Encrypts communication over the internet.</li><li><strong>AES Encryption</strong> — Protects stored sensitive data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*T8e6TWY3BtCkvHhl.png" /></figure><h3>10.3 Threat Mitigation</h3><ul><li><strong>DDoS Protection</strong> — Uses firewalls and traffic filtering.</li><li><strong>SQL Injection &amp; XSS Prevention</strong> — Sanitizes user input to prevent attacks.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*-ZzJHJ9-us0VazOK.png" /></figure><h3>11. Scalability in System Design</h3><p>Scalability is the ability of a system to handle increasing loads efficiently. It ensures that an application can support more users, data, and transactions without degrading performance.</p><h3>11.1 Vertical Scaling (Scaling Up)</h3><ul><li>Involves adding more resources (CPU, RAM) to an existing server.</li><li><strong>Pros</strong>: Simple to implement.</li><li><strong>Cons</strong>: Expensive and has hardware limitations.</li></ul><p><strong>Example</strong>: Upgrading a database server to a more powerful machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*pp_FLosmomukY8o-.png" /></figure><h3>11.2 Horizontal Scaling (Scaling Out)</h3><ul><li>Involves adding more servers to distribute the workload.</li><li><strong>Pros</strong>: More cost-effective and provides high availability.</li><li><strong>Cons</strong>: Requires load balancing and distributed data management.</li></ul><p><strong>Example</strong>: Adding multiple servers to handle web traffic for an e-commerce site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*qXuBR0DAVghEqbzF.png" /></figure><h3>11.3 Distributed Systems for Scalability</h3><ul><li><strong>Databases</strong>: Using Sharding, replication, and distributed SQL engines.</li><li><strong>Microservices</strong>: Dividing an application into independent services to allow better scaling.</li><li><strong>CDN (Content Delivery Network)</strong>: Caching static content across multiple locations globally.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*fGaCNQdh2aDQJHPn.png" /></figure><h3>12. System Design for High Availability and Fault Tolerance</h3><p>High availability ensures that a system remains operational even during failures. Fault tolerance is the ability of a system to recover from hardware/software failures.</p><h3>12.1 Redundancy and Failover Mechanisms</h3><ul><li><strong>Active-Passive Setup</strong>: One server is active, and a standby server takes over during failure.</li><li><strong>Active-Active Setup</strong>: Multiple servers handle traffic simultaneously for better fault tolerance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*tkzL8-aMn3kbYuGt.png" /></figure><h3>12.2 Data Replication Strategies</h3><ul><li><strong>Master-Slave Replication</strong>: The master database handles writes, while replicas handle read requests.</li><li><strong>Multi-Master Replication</strong>: Multiple databases handle both read and write operations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*0KdPUjR6VO8DOcuJ.png" /></figure><h3>12.3 Disaster Recovery</h3><ul><li><strong>Backups</strong>: Regular snapshots of critical data.</li><li><strong>Geo-Redundancy</strong>: Deploying services in multiple geographical regions to ensure reliability.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*OuysSg8NU6VtpaZF.png" /></figure><h3>13. System Design Interview Preparation</h3><p>System design interviews are crucial for software engineers aiming for top tech companies.</p><h3>13.1 Key Concepts to Focus On</h3><ul><li>Scalability, load balancing, and caching strategies.</li><li>Database design and replication techniques.</li><li>Security, authentication, and API design best practices.</li></ul><h3>13.2 Approach to Solving System Design Problems</h3><ul><li><strong>Step 1</strong>: Clarify requirements and constraints.</li><li><strong>Step 2</strong>: Define high-level architecture.</li><li><strong>Step 3</strong>: Identify key components (APIs, databases, caching, etc.).</li><li><strong>Step 4</strong>: Optimize for scalability, performance, and security.</li></ul><h3>13.3 Common System Design Problems</h3><ul><li>Design a URL shortening service (like <a href="http://bit.ly/">Bit.ly</a>).</li><li>Design a messaging system (like WhatsApp).</li><li>Design a video streaming platform (like YouTube).</li></ul><h3>14. Tools and Technologies for System Design</h3><p>Various tools and technologies aid in designing scalable and efficient systems.</p><h3>14.1 Databases</h3><ul><li>SQL: MySQL, PostgreSQL</li><li>NoSQL: MongoDB, Cassandra</li></ul><h3>14.2 Load Balancing and Caching</h3><ul><li>Load Balancers: Nginx, HAProxy</li><li>Caching: Redis, Memcached</li></ul><h3>14.3 Message Queues and Event Processing</h3><ul><li>Apache Kafka, RabbitMQ, Amazon SQS</li></ul><h3>14.4 Cloud Computing Services</h3><ul><li>AWS, Google Cloud, Microsoft Azure</li></ul><h3>15. Conclusion</h3><p>System design is a fundamental aspect of software development, enabling applications to scale, perform efficiently, and remain secure.</p><p>Whether designing a small application or a large distributed system, understanding key components like architecture, databases, load balancing, and caching is crucial.</p><p>For aspiring engineers, mastering system design concepts is essential for building real-world applications and succeeding in technical interviews.</p><p>By following best practices and staying updated with emerging trends, developers can design highly scalable and fault-tolerant systems that cater to millions of users.</p><h3>FAQs</h3><h3>1. What is the difference between system design and software architecture?</h3><p>System design focuses on how components interact within a system, while software architecture defines the overall structure and principles guiding software development.</p><h3>2. Why is system design important in software engineering?</h3><p>It ensures scalability, performance, security, and maintainability, making applications robust and efficient.</p><h3>3. What are some real-world applications of system design?</h3><p>Popular applications include social media platforms, e-commerce websites, ride-sharing apps, and cloud-based services.</p><h3>4. What is the best way to learn system design?</h3><p>Start with fundamental concepts, study case studies of real-world systems, and practice designing applications through mock interviews.</p><h3>5. What are some common mistakes in system design?</h3><p>Overcomplicating architecture, ignoring scalability, poor database choices, and neglecting security considerations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f2a82f4adff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/interviewcafe/sd-01-introduction-to-system-design-6f2a82f4adff">SD-01: Introduction to System Design</a> was originally published in <a href="https://medium.com/interviewcafe">InterviewCafe</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Crack Java Interviews Like a Pro-Your Ultimate Guide is Finally Here!]]></title>
            <link>https://medium.com/interviewcafe/crack-java-interviews-like-a-pro-your-ultimate-guide-is-finally-here-8297d207f8dd?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/8297d207f8dd</guid>
            <category><![CDATA[java-interview]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[java-interview-questions]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Thu, 01 May 2025 20:10:03 GMT</pubDate>
            <atom:updated>2025-05-01T20:25:51.675Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Crack Java Interviews Like a Pro — Your Ultimate Guide is Finally Here!</h3><p>If you’re preparing for a Java interview — whether it’s your <strong>first tech job</strong>, an <strong>internal switch</strong>, or you’re eyeing <strong>FAANG roles</strong> — I’ve got something that can save you weeks of scattered prep…</p><p>📚 <strong>The Art of Cracking Java Interviews</strong><br>A complete, practical book written by <strong>Santosh Kumar Mishra (Software Engineer at Microsoft)</strong> — packed with everything you need to walk into your next interview with confidence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QeJdA9ILlkL1ryD7.png" /></figure><p>🛍️ <strong>Limited-Time Offer: Get 25% OFF</strong> using coupon code → CRACKJAVA25</p><p><a href="https://topmate.io/iamsantoshmishra/1490067?coupon_code=CRACKJAVA25">👉 Click here to buy now!</a></p><p>⏳ <strong>Don’t wait — this offer won’t last forever!</strong></p><h3>✨ Why This Book Is Different (And Worth Every Rupee)</h3><p>This isn’t just a theory dump. It’s structured, visual, hands-on, and <strong>interview-focused</strong> — trusted by over <strong>10,000+ learners and engineers</strong> already.</p><p>Below are <strong>reasons</strong> why this book is worth your attention 👇<br>(<em>And yes, I’ve attached real screenshots of the book itself for proof!</em>)</p><h4>💡 1. Real-Life Examples for Every Concept</h4><p>What makes this book stand out is how it relates <strong>every concept to real life</strong>. From <strong>ATM machines</strong> to <strong>medical capsules</strong>, it connects theory to the real world. Learning has never been this relatable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cFG09hbskZqllnXX.png" /></figure><h4>🧠 2. Covers All Core to Advanced Java Topics</h4><p>OOPs, Collections, Streams, Lambda, Threads, Design Patterns — all covered. No need to Google around anymore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-kDxbRP5dEFX2oBK.png" /></figure><h4>✍️ 3. Explained in Depth with Diagrams, Notes, Quick Notes etc.</h4><p>Every topic is made visual — with color-coded notes, quick summaries, and hand-drawn diagrams to make revision quick and easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZI68zFrDjBc0pcW1.png" /></figure><h4>💬 4. 500+ Java Interview Q&amp;A</h4><p>Questions are answered from <strong>brute-force to optimized</strong> with dry runs, real-world scenarios, and diagrams. Perfect for whiteboard rounds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YGvHpF5dHCVcToRp.png" /></figure><p>🎯 No fluff. Only high-impact answers.</p><h4>🧪 5. 300+ Chapter-Wise Quizzes</h4><p>Built-in self-assessments after every chapter. Practice real questions and track your progress immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dy9qIImHYQw1BwV2.png" /></figure><h4>💻 6. Chapter-Wise Mini Projects &amp; 30 Major Project Ideas</h4><p>You can’t just talk theory in interviews. Build confidence with real projects:</p><ul><li>Java + Spring Boot</li><li>REST APIs</li><li>CI/CD with Jenkins &amp; Docker</li><li>Food Delivery App</li><li>Job Portal System</li><li>…and so many more!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tMtyzpRQ26wdlQ50.png" /></figure><h4>🧳 7. Resume Tips, System Design &amp; Behavioural Interview Prep</h4><p>Learn how to make your resume ATS-friendly, answer HR questions with confidence, and nail Java-focused system design rounds. Everything in one place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DvPe4fDP31FfiGcm.png" /></figure><h4>⭐ 8. Recommended by Industry Experts</h4><p>Don’t just take our word for it — engineers at <strong>Google, Microsoft, Amazon</strong> have used and loved this book. It’s helped both <strong>freshers and experienced devs</strong> land their dream roles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9vGUj2c6n20P-XOz.png" /></figure><h4>🎁 Try Before You Buy — Sample Content Available</h4><p>Want a sneak peek before you grab it?</p><p>👉 <a href="https://drive.google.com/file/d/17RGKGBzE16PrTcfkNENQj5btDdkAp62Q/view?usp=drive_link">Download Free Sample Content</a></p><h4>🎯 Ready to Crack Java Interviews Like a Pro?</h4><p>🎁 Use code CRACKJAVA25 to get <strong>25% OFF</strong> your digital copy.</p><p>👉 <a href="https://topmate.io/iamsantoshmishra/1490067?coupon_code=CRACKJAVA25">Click Here to Buy Now!</a></p><p>⏳ This is a <strong>launch offer only</strong>, and it won’t stay live forever.</p><p>So if cracking Java interviews is your goal — <strong>invest in yourself now</strong>. Your future self will thank you. 💼</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8297d207f8dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/interviewcafe/crack-java-interviews-like-a-pro-your-ultimate-guide-is-finally-here-8297d207f8dd">🚀 Crack Java Interviews Like a Pro-Your Ultimate Guide is Finally Here!</a> was originally published in <a href="https://medium.com/interviewcafe">InterviewCafe</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merge Sort]]></title>
            <link>https://medium.com/@iamsantoshmishra/merge-sort-b4560d5572b4?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4560d5572b4</guid>
            <category><![CDATA[sorting]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[merge-sort]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Mon, 16 Jan 2023 17:18:36 GMT</pubDate>
            <atom:updated>2023-01-16T17:18:36.114Z</atom:updated>
            <content:encoded><![CDATA[<p>Merge Sort is a popular and efficient sorting algorithm that uses a divide-and-conquer strategy to sort an array or a list of elements. The basic idea behind merge sort is to divide the array into two halves, sort each half individually, and then merge the two sorted halves back together.</p><p>The algorithm starts by dividing the array into two equal parts, and then recursively applying the same process to each half. This process continues until we have an array of size 1, which is considered to be a sorted array. Once we have two sorted arrays, we can then merge them back together by comparing the elements of each array and adding them to a new array in the correct order.</p><p>The merge step is the key step of the algorithm, and it is where the efficiency of merge sort lies. By merging two sorted arrays, we can ensure that the final array is also sorted, and we can do this in linear time O(n).</p><p>One of the key advantages of merge sort is its stability. Stability refers to the property of sorting algorithm that preserves the relative order of elements with the same value. Merge sort is a stable sorting algorithm, meaning that the relative order of elements with the same value is preserved in the final sorted array.</p><p>Another advantage of merge sort is that it is a good choice for sorting large arrays or lists as it has a time complexity of O(n log n) which is much better than O(n²) for bubble sort and insertion sort.</p><p>However, merge sort is not an in-place sorting algorithm, meaning it requires additional memory space to store the two sub-arrays during the merge process. It is also not the best choice for small arrays or lists, as the overhead of the divide and conquer strategy may outweigh the benefits of the merge step.</p><p>Overall, merge sort is a reliable and efficient sorting algorithm that is well-suited for large arrays and lists. Its divide-and-conquer strategy and linear time merge step to make it a stable and fast choice for sorting data.</p><p>Here is an example of a Python implementation of the merge sort algorithm:</p><pre>def merge_sort(arr):<br>    if len(arr) &lt;= 1:<br>        return arr<br>    mid = len(arr) // 2<br>    left_half = arr[:mid]<br>    right_half = arr[mid:]<br>    left_half = merge_sort(left_half)<br>    right_half = merge_sort(right_half)<br>    return merge(left_half, right_half)<br><br>def merge(left, right):<br>    result = []<br>    i = 0<br>    j = 0<br>    while i &lt; len(left) and j &lt; len(right):<br>        if left[i] &lt;= right[j]:<br>            result.append(left[i])<br>            i += 1<br>        else:<br>            result.append(right[j])<br>            j += 1<br>    result += left[i:]<br>    result += right[j:]<br>    return result<br><br>arr = [5, 2, 9, 1, 5, 6]<br>print(merge_sort(arr)) # Output: [1, 2, 5, 5, 6, 9]</pre><p>This implementation uses the divide and conquers strategy to recursively divide the input array into smaller sub-arrays until we reach sub-arrays of size 1, which are considered to be sorted. The merge function is then used to merge the sorted sub-arrays back together in the correct order.</p><p>The merge function takes two input arrays, left and right, and uses a while loop to compare and combine the elements of the two arrays into a new result array. It also handles the case where one array may have more elements than the other by adding any remaining elements to the result array.</p><p>It’s worth noting that the above implementation sorts the array in ascending order, if you want to sort in descending order you should change the comparison operator from &lt;= to &gt;= in the merge function.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4560d5572b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Search a 2D Matrix]]></title>
            <link>https://medium.com/@iamsantoshmishra/search-a-2d-matrix-de4bfe84fa76?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/de4bfe84fa76</guid>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 02:32:00 GMT</pubDate>
            <atom:updated>2022-12-10T02:32:00.272Z</atom:updated>
            <content:encoded><![CDATA[<p>You are given a m x n integer matrix and a target value and we need to find whether the target is in matrix or not. The matrix has the following properties:</p><ul><li>Integers in each row are sorted from left to right.</li><li>The first integer of each row is greater than the last integer of the previous row.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*bHr8LtYXH6R8kQS2GklrHQ.png" /></figure><pre>Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 30<br>Output: true</pre><blockquote><strong><em>Approach</em></strong></blockquote><p>— Traversing the entire matrix to find target using two loops will be definitely a bad idea. As the worst case time complexity will be <strong>O(m x n)</strong> where ‘m’ and ’n’ are no. of rows &amp; columns respectively.</p><p>— The general idea can be storing all the elements of matrix in a 1-D array and applying Binary Search will be good idea making time complexity <strong>O(log(m x n))</strong>. But we need to allocate an auxiliary space for 1-D array.</p><p>— So, let us think about some other optimized approaches. As the given matrix has some properties like each row has elements in sorted order and first element of each row is greater than the last element of previous row, let’s try to apply <strong>“<em>divide and conquer method</em>”</strong> and perform “<strong>Binary Search”</strong> in<strong> </strong>matrix.</p><p>— First, we need to move to the row where the target value is present. This can be done by simply moving from each row to next if target is greater than last element of current row, otherwise stop at that row and then apply binary search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*XUgJjvLTS7QAt0wD30ONMA.png" /></figure><p>— Let’s try to find out the time complexity for this approach. At worst case, we may need to move to last row when target value is in last row. So time complexity will be O(m) and to perform binary search in that row takes O(logn). Total time complexity is <strong>O(m)+O(logn)</strong>.</p><p>— We can further optimize this to O(logm)+O(logn)<strong> </strong>which is equals to <strong>O(log(m x n)) </strong>by finding the target row using binary search, so that we need not to traverse each row like in the above approach.</p><p>Finding the row using binary search with an example of target = 31 and m x n = 6 x 4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yBTHrGRQ_-TPjk3DzJd_pQ.png" /><figcaption>Considering last column of matrix to get target row using binary search</figcaption></figure><p>— After getting the row number we can perform the normal binary search again in that specific row to find the target. By this way, time complexity will be O(log(m x n)) without any need of extra 1-d array.</p><pre>class Solution {<br>    public boolean searchMatrix(int[][] matrix, int target) {<br>        for(int i = 0;i &lt; matrix.length; i++){<br>            if(target &gt; matrix[i][matrix[i].length-1])<br>                continue;<br>            int start = 0,end = matrix[i].length-1;<br>            while(a &lt;= b){<br>                int mid = (a + b) / 2;<br>                if(matrix[i][mid] == target)<br>                    return true;<br>                else if(target &lt; matrix[i][mid])<br>                    b = mid - 1;<br>                else a = mid + 1;<br>            }<br>        }<br>        return false;<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de4bfe84fa76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rotate List]]></title>
            <link>https://medium.com/@iamsantoshmishra/rotate-list-81660295fc7d?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/81660295fc7d</guid>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Fri, 09 Dec 2022 14:36:14 GMT</pubDate>
            <atom:updated>2022-12-09T14:36:14.633Z</atom:updated>
            <content:encoded><![CDATA[<p>Given the head of a linked list, rotate the list to the right by k places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/0*yA53TydbRsaYkCY5.jpg" /></figure><p><strong>Input:</strong> head = [1,2,3,4,5], k = 2</p><p><strong>Output:</strong> [4,5,1,2,3]</p><blockquote><strong>Approach:</strong></blockquote><p>— Rotating the list by ‘k’ places means indirectly the last ‘k’ nodes should be attached to the starting nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/0*o6AqEjvg8AriIu_u" /></figure><p>— The approach is that we need to traverse up to the node where there are ‘k’ nodes remained in the list (here up to node 4). This can be done by finding length of linked list and moving ‘length-k’ times from the head. And place a pointer at that node let’s say newHead. And place another pointer ‘prev’ at previous node of our newHead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*JeYrvhV2nW3WlyCo" /></figure><p>— If ‘k’ is greater than or equals to length of the list, perform k%length times as we get the original list every time after rotating ’n’ times, where ’n’ is the number of nodes in list.</p><p>— Link last node of linked list with the initial head and place ‘null’ in next field of ‘prev’ node and finally update head with the newHead and return head.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*9Ebj_NkJtq5pWYrw" /></figure><p>— Corner test cases are when the list has no nodes or the list has only one node. In those cases, just return the head.</p><blockquote><strong>Code:</strong></blockquote><pre>class Solution {<br>    public ListNode rotateRight(ListNode head, int k) {<br>        int length = 0, i = 0;<br>        ListNode temp = head;<br>        ListNode lastNode = null, prev = null;<br>        if(head == null || head.next == null)<br>            return head;<br>        <br>        // finding length of list<br>        while(temp != null){<br>            length++;<br>            if(temp.next == null)<br>                lastNode = temp;<br>            temp = temp.next;<br>        }<br>        temp = head;<br>        k = k % length;<br>        if(k == 0)<br>            return head;<br>  <br>        //moving to the newHead node<br>        while(i &lt; length-k){<br>            prev = temp;<br>            temp = temp.next;<br>            i++;<br>        }<br>        lastNode.next = head;<br>        head = temp;<br>        prev.next = null;<br>        return head;<br>    }<br>}</pre><p>Time Complexity: O(n)</p><p>Space Complexity: O(1)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81660295fc7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Load Balancers]]></title>
            <link>https://medium.com/@iamsantoshmishra/load-balancers-11281e314199?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/11281e314199</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[load-balancer]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Tue, 15 Nov 2022 14:07:11 GMT</pubDate>
            <atom:updated>2023-01-01T19:12:35.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tNoOJRiPBMhUNXg-.jpg" /></figure><h3>WHY LOAD BALANCERS ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dmQMS39lTsTyxWSk.png" /></figure><p>When the user base grows, our application will experience <strong>high traffic</strong> and the <strong>load</strong> on a single server also increases.</p><p>This concurrent traffic <strong>overwhelms </strong>the single server and the performance of the application is impacted severely.</p><p><strong><em>One server would be serving all traffic. </em></strong>At some point this server would be exhausted by independently handling all the requests.</p><p><strong><em>NOTE :</em></strong> Website traffic/load refers to <strong>web users who visit a website</strong></p><p><strong>The problem with having a single server is:</strong></p><blockquote><strong>Single Point of Failure : </strong>If this server is facing some catastrophic issues or goes down entirely the whole working of application will be interrupted and will become unavailable for the users until this issues is resolved. This may lead to bad user experience .</blockquote><blockquote><strong>Overloaded Servers : </strong>There is a strong limitation on the number of requests that one web server can handle. If the business grows and the traffic increases the server will be overloaded by bombarding requests. The performace of the application is also impacted.</blockquote><p><strong>To handle this heavy traffic, we need to scale our system.</strong></p><p>A system can be <strong>scaled</strong> in two ways:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*Oo7ObCGyQTkh-6S8nII26A.png" /></figure><blockquote><strong>Vertically Scalable : </strong>Vertical scaling refers to <strong>adding more resources (CPU/RAM/DISK) to your server.</strong></blockquote><blockquote><strong>Horizontally Scalable : </strong>Horizontal scaling (aka scaling out) refers to adding additional nodes to your existing infrastructure to cope with new demands.</blockquote><p>We will take into consideration only horizontal scalability from now on when discussing about scalability, cause at some point it would be cheaper to <strong>add more servers to the system rather than to add resources to existing server.</strong></p><p>So now that we have added more servers, the <strong>traffic can be distributed</strong> among all these servers to handle the increasing load and serve the requests at a faster pace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*G1OLBLbM7JBQFdjH.png" /></figure><p><strong>Who is going to decide which request should be routed to which server???</strong></p><p>This is where load balancing comes into picture.</p><h3>WHAT IS LOAD BALANCER?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vrhBzlhfPMdan8TB.png" /></figure><p>Load balancer <strong>distributes </strong>the load <strong>uniformly</strong> across multiple available servers thus improving overall application <strong>availability and responsiveness.</strong></p><p>It simply distributes the set of requested operations (like database write requests, cache queries etc) <strong>effectively </strong>across multiple servers and ensures that no single server <strong>bears</strong> too many requests that lead to degrading the overall performance of the application.</p><p>Load balancer allows the services to handle any number of requests by adding any number of web servers in the network(horizontal scalability).</p><p>The requests are spread across multiple active servers. Hence if one of the server goes down, all the requests of this server would be re-directed to other active server without dropping those requests.</p><h3>Where Are Load Balancers Typically Placed?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*0jmgHH2axxmwGqBuzvpcYA.png" /></figure><p>Load balancers can be placed in between :</p><ul><li>The client/user and the web server</li><li>The web server and the application servers</li><li>The application servers and the cache servers</li><li>The cache servers the database server</li></ul><h3>Benefits of Load Balancers</h3><ul><li>Users experience faster, uninterrupted service.</li><li>The failure of a server does not effect the system greatly as the load balancer will simply re-route the requests to healthy servers.</li><li>Service providers experience less downtime and higher throughput and also decreases wait time for users.</li><li>Smart load balancers have the <strong>ability to predict traffic bottelnecks</strong> before they happen, so that the system administrator can take actionable insights.</li><li>System experiences <strong>fewer failed or stressed components </strong>since the load is distributed among various server thus enabling each server to work within their capacity.</li></ul><p>Load balancer could also be a<strong> single point of failure.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*GF_AA9D0T9MBwfkI.png" /></figure><p>Hence we can have :</p><p><strong>Active-Passive : </strong>In active-passive configuration model ; one load balancer is responsible for distributing the entire traffic and other load balancer is in <strong>standby mode</strong> and is activated in the <strong>event of failure</strong> of the active load balancer.</p><p><strong>Active-Active : </strong>In active-active model both the load balancers are active and takes equal responsibility of distributing traffic and monitor the status oif each other occasionally.</p><h3>Load Balancing Algorithms</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7hlrrFq1k0ERCf3S.jpg" /></figure><p><strong>So now the question arises on what criteria does the load balancer decide which requests goes to which server ?</strong></p><p>The load is not randomly distributed across the pool of servers.</p><p>There are several load balancing algorithms in place to decide which request should be routed to which server.</p><p><strong>NOTE: <em>Dynamic load balancers preconfigure the active servers in the cluster and route the requests to only those servers that are active(alive).</em></strong></p><p><strong>How does the load balancer keep track of the status of servers ?</strong></p><p>LBs use the <a href="https://en.wikipedia.org/wiki/Heartbeat_(computing)"><strong>heartbeat protocol</strong></a><strong> </strong>to monitor the health of servers periodically and keep track of the status of the servers for assigning the requests.</p><p><strong>Some of the common load balancing algorithms are given below:</strong></p><h4>1. Round Robin</h4><p>Requests are distributed across the servers in a <strong>sequential or rotational manner</strong>.</p><p>For example, Let’s say we have ’n’ servers the first request goes to the first server, the second one goes to the second server, the ‘n’ request goes to ‘n’ server and ‘n+1&#39; request is routed to the first server.</p><h4>2. Weighted Round Robin</h4><p>It is much similar to the round-robin technique. The only difference is, that each of the servers in the list is provided a weighted score.</p><p>Depending on the weighted score the request is distributed to these servers. So the servers with higher weight will get bigger share of the overall requests.</p><h4>3. Least Connection Method</h4><p>In this method, the request will be directed to the server with the <strong>least number of requests or active connections</strong>.</p><p>So assignment of requests to servers is based on the current load of the server.</p><p><strong>NOTE : </strong>This algorithm is most useful when there is a huge number of persistent connections in the traffic unevenly distributed between the servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7sNPB8cg0hBf9W2eLfiBvw.png" /></figure><h4>4. Least Response Time Method</h4><p>In this method, the request is forwarded to the server with the <strong>least active connections</strong>(or requests) <strong>and</strong> the <strong>least average response time</strong>.</p><p>The response time taken of the server depends on the current load on the server and the overall expected user experience.</p><h4>5. Source IP Hash</h4><p>In this method, the request is sent to the server based on the client’s IP address. A hash is computed from IP address using some cryptographic algorithm and the requests are assigned to servers based on this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*XxA2vGfadbwIuEcu5pblXQ.png" /></figure><p><strong><em>A load balancer enables elastic scalability of the application which drastically improves the performance, resilience and throughput of the system.</em></strong></p><p><em>Follow me for more interesting blogs on System Design.</em></p><p><em>Connect with me here </em>👇</p><p><a href="https://www.linkedin.com/in/iamsantoshmishra"><strong>LinkedIn</strong></a> , <a href="https://www.instagram.com/iamsantoshmishra/"><strong>Instagram</strong></a> , <a href="https://bit.ly/3TYSQLX"><strong>Youtube</strong></a>, <a href="https://t.me/interviewcafenotes"><strong>Telegram-Channel</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11281e314199" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[   ]]></title>
            <link>https://medium.com/@iamsantoshmishra/reverse-linked-list-f44a1f92e66b?source=rss-72e30f05d5aa------2</link>
            <guid isPermaLink="false">https://medium.com/p/f44a1f92e66b</guid>
            <dc:creator><![CDATA[Santosh Kumar Mishra]]></dc:creator>
            <pubDate>Mon, 14 Nov 2022 15:46:37 GMT</pubDate>
            <atom:updated>2022-11-16T06:02:10.128Z</atom:updated>
            <content:encoded><![CDATA[<p>We have given the head of a singly linked list, reversed the list, and returned <em>the reversed list</em>.</p><p>Whenever I heard “Reverse” problem so, the solution that came to my mind is to use “Stack”. I know that the brute force approach also takes O(n) extra space.</p><p>I hope you are able to identify the intuition behind why I’m using stack. If not go through the principle rule of the stack which is “LIFO” ( Last In First Out). due to its <strong>LIFO</strong> property, a stack is able to store elements in reverse order of their insertion and hence can be used to solve our problem.</p><p>So, how can we proceed further with this approach :</p><blockquote><strong>1.</strong> Create an empty stack.<br><strong>2.</strong> Iterate through the linked list and push the values of the nodes into the stack.<br><strong>3.</strong> Now, after the iteration is complete, the linked list is stored in reverse order in the stack.<br><strong>4.</strong> Now, start popping the elements from the stack and iterating through the linked list together, and change the values in the nodes by the values we get from the stack.<br><strong>5.</strong> Finally after stack got empty, we will have the required reversed linked list.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v5U2MDByl-igEEJSXUMarA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PKH9wAW4OM4xCcdpPzY_YA.png" /><figcaption><strong>push node 1 in stack.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCYDiKSRdtArzP2fuvG_Vw.png" /><figcaption><strong>push node 2 in the stack.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMwPALjMOuo-IAZKox674g.png" /><figcaption><strong>push node 3 in the stack.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ExkkUrDK3g8cZodwpphAzQ.png" /><figcaption><strong>now, curr.next == null so we are not going to add node 4 in our stack which is our last node. make That curr Node as “Head”.</strong></figcaption></figure><p>Pop Operation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zqSnqQJ_MElVj_y_ca4aKQ.png" /><figcaption><strong>makes our last node as “Head” node.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FX2lBWbBJyQHAGMj2fSVYA.png" /><figcaption><strong>pop node 3 from the stack, and curr.next = stack.pop(). And curr = curr.next.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-ZNzmTgzSxrTQvADodZhQ.png" /><figcaption><strong>pop node 2 from the stack and do curr. next = stack.pop() ,and curr = curr.next.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yD3D_rfNRVCHnjpojVxcmg.png" /><figcaption><strong>pop node 1 from the stack and do curr.next = stack.pop() , and curr = curr.next.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxGcmwKlEgc2kGHYBJGy3Q.png" /><figcaption><strong>now, the stack is empty then do curr.next =null.</strong></figcaption></figure><p>Brute Force Code :</p><pre>static Node reverseList(Node head){<br><br>        Stack&lt;Node&gt; stack = new Stack&lt;&gt;();<br><br>        Node curr = head;<br>        while(curr.next != null){<br>            stack.push(curr);<br>            curr = curr.next;<br>        }<br><br>        head = curr;<br>        while(!stack.isEmpty()){<br>            curr.next = stack.peek();<br>            curr = curr.next;<br>            stack.pop();<br>        }<br><br>        curr.next = null;<br>        return head;<br><br>    }</pre><p>Time-Complexity — O(N) <br>Space-Complexity — O(N) , N is the number of Nodes in LinkedList.</p><h3>Iterative Approach :</h3><p>How can we optimize it much further, How to come up with an optimal solution in an Interview?</p><p>Here comes the Iterative Approach, Let’s talk about it.<br>The idea is to use three pointers <strong>curr</strong>, <strong>prev,</strong> and temp to keep track of nodes to update reverse links.</p><p>How can we proceed further with this approach :</p><blockquote><strong>1.</strong> Initialize three pointers <strong>prev</strong> as NULL, <strong>curr</strong> as <strong>head</strong>, and temp as NULL.<br><strong>2. </strong>While traversing the list, we can change the current node’s next pointer to point to its previous element. Since a node does not have reference to its previous node, we must store its previous element beforehand. We also need another pointer to store the next node before changing the reference. Do not forget to return the new head reference at the end!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7qVAU-TquuOPy2ijfzHCw.png" /><figcaption>Initialize three pointers <strong>prev</strong> as NULL, <strong>curr</strong> as <strong>head</strong>, and temp as NULL.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOmjYRuEZVyPP-3Gwkh5Fw.png" /><figcaption>temp = curr.next , so we don’t wanna lose curr next link.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Nq1woT3AycqN995NN_FpQ.png" /><figcaption>Now, point curr next to prev.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dain8jsOOuAKaXCrevHJfQ.png" /><figcaption>update prev to curr.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aK2J9V6c30KsMJ-nQVyn5w.png" /><figcaption>Now update curr next to temp, where we have store curr.next previously.</figcaption></figure><p>And so on…..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lh9qA5jsYjl5dULmg8agQ.png" /><figcaption>Here is our final Linked List.</figcaption></figure><p><strong>Code :</strong></p><pre>class Solution {<br>    public ListNode reverseList(ListNode head) {<br>        <br>        ListNode prev = null;<br>        ListNode curr = head;<br>        ListNode temp = null;<br>        <br>        while(curr != null){<br>            temp = curr.next;<br>            curr.next = prev;<br>            prev = curr;<br>            curr = temp;<br>        }<br>        <br>        return prev;<br>    }<br>}</pre><p>Time-Complexity — O(N), N is the number of Nodes in LinkedList.<br>Space-Complexity — O(1)</p><p>Do Follow for More !!</p><p><a href="https://www.linkedin.com/in/iamsantoshmishra"><strong>LinkedIn</strong></a><strong> </strong><a href="https://www.instagram.com/iamsantoshmishra"><strong>Instagram</strong></a><strong> </strong><a href="https://youtu.be/GP4k31mVcIg"><strong>YouTube</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f44a1f92e66b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>