<?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 Vidhi koul on Medium]]></title>
        <description><![CDATA[Stories by Vidhi koul on Medium]]></description>
        <link>https://medium.com/@koulvidhi2?source=rss-ce4d335e8ce4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*AmZnWKZ1ZrZTsw1r</url>
            <title>Stories by Vidhi koul on Medium</title>
            <link>https://medium.com/@koulvidhi2?source=rss-ce4d335e8ce4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:01:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@koulvidhi2/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[  : _  _ — ’ ?]]></title>
            <link>https://medium.com/@koulvidhi2/-57ec8bc1dd43?source=rss-ce4d335e8ce4------2</link>
            <guid isPermaLink="false">https://medium.com/p/57ec8bc1dd43</guid>
            <category><![CDATA[competitive-programming]]></category>
            <category><![CDATA[good-programming-practice]]></category>
            <category><![CDATA[stl]]></category>
            <category><![CDATA[cpp-programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Vidhi koul]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 13:00:31 GMT</pubDate>
            <atom:updated>2025-09-14T13:02:33.105Z</atom:updated>
            <content:encoded><![CDATA[<h3>𝗕𝗮𝘁𝘁𝗹𝗲 𝗼𝗳 𝗦𝗧𝗟: 𝗽𝘂𝘀𝗵_𝗯𝗮𝗰𝗸 𝘃𝘀 𝗲𝗺𝗽𝗹𝗮𝗰𝗲_𝗯𝗮𝗰𝗸 — 𝗪𝗵𝗼’𝘀 𝗙𝗮𝘀𝘁𝗲𝗿?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INsZpFehuIOw2X3ZQoG07g.png" /><figcaption>push_back VS emplace_back</figcaption></figure><p>C++ STL is full of little optimisations that can make a huge difference in performance when dealing with large datasets. One such pair of functions that often causes confusion is push_back vs emplace_back.</p><p>Let’s break it down in simple terms.</p><h3>The Basics</h3><ul><li><strong>push_back</strong> → Adds an element to the end of a container by copying or moving it.</li><li><strong>emplace_back</strong> → Constructs the element directly at the end of the container (in-place construction).</li></ul><h3>Example:</h3><pre>#include &lt;bits/stdc++.h&gt;<br>using namespace std;</pre><pre>struct Student {<br>    string name;<br>    int age;<br>    Student(string n, int a) : name(n), age(a) {<br>        cout &lt;&lt; &quot;Constructor called for &quot; &lt;&lt; name &lt;&lt; endl;<br>    }<br>    Student(const Student&amp; s) {<br>        cout &lt;&lt; &quot;Copy constructor called for &quot; &lt;&lt; s.name &lt;&lt; endl;<br>    }<br>};</pre><pre>int main() {<br>    vector&lt;Student&gt; students;<br>    <br>    cout &lt;&lt; &quot;--- Using push_back ---&quot; &lt;&lt; endl;<br>    students.push_back(Student(&quot;Gita&quot;, 21));<br>    <br>    cout &lt;&lt; &quot;--- Using emplace_back ---&quot; &lt;&lt; endl;<br>    students.emplace_back(&quot;Sita&quot;, 20);<br>}</pre><h3>Output:</h3><pre>--- Using push_back ---<br>Constructor called for Gita<br>Copy constructor called for Gita</pre><pre>--- Using emplace_back ---<br>Constructor called for Sita</pre><p>Notice the difference:</p><ul><li>With push_back, the object is constructed <strong>outside</strong> and then copied/moved inside the vector.</li><li>With emplace_back, it is constructed <strong>directly inside the vector</strong> → avoiding the extra copy.</li></ul><h3>When to Use What?</h3><ul><li>Use emplace_back when you are creating an object directly in the container.</li><li>Use push_back when you already have an object created.</li></ul><p>Example:</p><pre>Student s(&quot;Ram&quot;, 22);<br>students.push_back(s);   // Correct<br>students.emplace_back(s); // Not efficient here</pre><h3>Performance Impact</h3><p>For <strong>lightweight objects</strong> like integers or chars → negligible difference.<br>For <strong>complex objects</strong> (like classes with expensive constructors, strings, pairs, or nested containers) → emplace_back gives a significant performance boost.</p><h3>Takeaway</h3><p>emplace_back is not just syntactic sugar. It allows <strong>direct in-place construction</strong>, reducing unnecessary copies or moves, making your code both faster and cleaner.</p><p>👉 Rule of thumb:</p><ul><li>If constructing on the fly → use emplace_back.</li><li>If you already have the object → use push_back.</li></ul><p>⚡ Small change, big impact. That’s the beauty of C++!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57ec8bc1dd43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“The Justin Bieber Problem: When Celebrities Break the Internet (and How Engineers Fix It)”]]></title>
            <link>https://medium.com/@koulvidhi2/the-justin-bieber-problem-when-celebrities-break-the-internet-and-how-engineers-fix-it-0350dee56295?source=rss-ce4d335e8ce4------2</link>
            <guid isPermaLink="false">https://medium.com/p/0350dee56295</guid>
            <category><![CDATA[instagram-likes]]></category>
            <category><![CDATA[justin-beiber]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[scaling]]></category>
            <dc:creator><![CDATA[Vidhi koul]]></dc:creator>
            <pubDate>Sat, 06 Sep 2025 07:53:53 GMT</pubDate>
            <atom:updated>2025-09-06T07:53:53.300Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*VYW5EibdaBZ8NTA4eJ5LOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bsrT3K2QJX3Vd9T-534Vug.png" /></figure><h3>1. Introduction: When Bieber Broke Instagram</h3><p>At the peak of Instagram’s growth, one unexpected challenge shook the engineering team: <strong>Justin Bieber’s posts.</strong></p><p>Every time Bieber shared a photo, <strong>millions of fans rushed simultaneously</strong> to view, like, and comment. The result? Instagram slowed down, servers overloaded, and counters lagged.</p><p>This phenomenon became known as the <strong>Justin Bieber Problem</strong> — a system design case study on how to handle <strong>hotspots</strong> and <strong>viral traffic</strong> in distributed systems.</p><h3>2. Why is This a Hard Problem?</h3><p>Most systems are designed for <em>average load</em>. But social media has <strong>bursty, celebrity-driven spikes</strong>.</p><ul><li><strong>Read-heavy load:</strong> Millions try to fetch the same content (image, video).</li><li><strong>Write-heavy load:</strong> Millions simultaneously like or comment, stressing DB counters.</li><li><strong>Hotspot formation:</strong> Instead of spreading evenly, all traffic targets <em>one</em> post or <em>one</em> DB row.</li></ul><p>This is not just about Bieber — the same problem happens with tweets, viral YouTube videos, or flash sales on e-commerce platforms.</p><h3>3. Instagram’s First Fix: Caching for Reads</h3><p>When millions of fans want to see the same post:</p><ul><li>Without caching → each request hits the database.</li><li>With caching → store the post in memory (Memcached / Redis) and serve it directly.</li></ul><p><strong>Effect:</strong></p><ul><li>Read latency dropped dramatically.</li><li>DB load reduced.</li><li>Users could instantly view content without hammering the database.</li></ul><p>But caching solved <strong>reads</strong>, not <strong>writes</strong>. The like counter still melted under pressure.</p><h3>4. The Bigger Challenge: The Like Counter ❤️</h3><p>Likes were the real bottleneck.</p><p>Imagine one row in the database tracking likes:</p><pre>PostID | LikeCount<br>12345  | 999,999,999</pre><p>Now millions of users press ❤️ in seconds.</p><ul><li>Every request wants to <strong>increment the same row</strong>.</li><li>Database locks cause contention.</li><li>System slows or even crashes.</li></ul><h3>5. The Solution: Sharded Counters</h3><p>Instead of <strong>one counter</strong>, Instagram engineers broke it into <strong>multiple counters (shards)</strong>.</p><p><strong>How it works:</strong></p><ol><li>Create N shards for a post (say 100).</li><li>Each like request is randomly assigned to a shard.</li><li>Each shard maintains its own count.</li><li>The total likes = sum of all shard counts.</li></ol><p><strong>Example:</strong></p><pre>Shard 1 → 10,000 likes  <br>Shard 2 → 9,500 likes  <br>...  <br>Shard 100 → 10,200 likes  <br>Total = 29,700 likes</pre><p>No single shard gets overloaded.<br>Writes scale linearly with the number of shards.</p><h3>6. Why Sharded Counters Work</h3><ul><li><strong>Distributes writes</strong> → Avoids hotspot on a single DB row.</li><li><strong>Increases throughput</strong> → Multiple shards can handle requests in parallel.</li><li><strong>Accepts eventual consistency</strong> → Users don’t need <em>perfectly accurate</em> counts instantly.</li></ul><p><strong>Tradeoff:</strong> Sometimes you’ll see slightly stale numbers (“29.7k likes” instead of exact count). But for social media, this is acceptable.</p><h3>7. The Bigger Lesson: Hotspot Handling</h3><p>The Justin Bieber Problem is a <strong>hotspot problem</strong> in distributed systems.<br> Solutions include:</p><ul><li><strong>Caching</strong> → for high read volume.</li><li><strong>Sharding</strong> → for high write volume.</li><li><strong>Load balancing</strong> → spread requests across servers.</li><li><strong>Approximation + Eventual Consistency</strong> → exactness is sacrificed for scale.</li></ul><h3>8. Applications Beyond Instagram</h3><p>The Bieber Problem shows up everywhere:</p><ul><li><strong>Twitter Trends:</strong> Millions tweeting about one hashtag.</li><li><strong>YouTube Views:</strong> Viral videos get billions of reads + concurrent updates.</li><li><strong>Flash Sales on Amazon:</strong> A single product becomes a hotspot.</li><li><strong>Payment Gateways:</strong> Sudden festival sales cause write-heavy traffic.</li></ul><h3>9. Closing Thoughts</h3><p>The Justin Bieber Problem isn’t about one celebrity — it’s about designing systems that can handle <em>viral, uneven, bursty traffic</em>.</p><p>The key takeaway?<br> Scale isn’t about averages, it’s about <strong>peaks</strong>.<br> Build for hotspots, because that’s when systems are truly stress-tested.</p><p>So next time you double-tap on a viral post, remember — there’s a whole architecture behind that simple ❤️.</p><p>As engineers, these are the problems that make us proud of what we do — building systems that can withstand celebrity moments and truly scale.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0350dee56295" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ The Hidden Gem Powering Search at Scale: Inside Apache Lucene]]></title>
            <link>https://medium.com/@koulvidhi2/the-hidden-gem-powering-search-at-scale-inside-apache-lucene-e35c71617ebf?source=rss-ce4d335e8ce4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e35c71617ebf</guid>
            <category><![CDATA[search-engines]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[hidden-gems]]></category>
            <category><![CDATA[tf-idf]]></category>
            <category><![CDATA[apache-lucene]]></category>
            <dc:creator><![CDATA[Vidhi koul]]></dc:creator>
            <pubDate>Sun, 22 Jun 2025 05:41:45 GMT</pubDate>
            <atom:updated>2025-06-22T05:41:45.389Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>💎 The Hidden Gem Powering Search at Scale: Inside Apache Lucene</blockquote><blockquote><em>It’s the quiet ones who do the heavy lifting.In the world of tech, </em><strong><em>Apache Lucene</em></strong><em> is exactly that — a silent powerhouse behind high-speed search at Google, Netflix, and Wikipedia.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUyDSAFwUswH_WQH77BL-g.png" /></figure><h3>🔍 What Is Apache Lucene?</h3><p>Apache Lucene is a <strong>high-performance, full-featured text search engine library</strong> written in Java.It’s not a ready-to-use search engine (like Elasticsearch), but rather a <strong>toolkit</strong> that developers can embed in their own applications to power full-text search and retrieval.</p><p>Lucene is the <strong>core</strong> of systems like:</p><ul><li><strong>Elasticsearch</strong></li><li><strong>OpenSearch</strong></li><li><strong>Solr</strong></li><li>Even parts of <strong>Amazon CloudSearch</strong></li></ul><h3>⚙️ How Does Lucene Work?</h3><p>At its core, Lucene uses two fundamental concepts:</p><h4>1. Inverted Index</h4><p>This is the <em>engine</em> behind Lucene.<em>Instead of mapping documents to words (like traditional databases), Lucene maps </em><strong><em>words to documents</em></strong><em> — allowing fast retrieval.</em></p><p><strong>Example:</strong><br> Suppose we have 3 documents:</p><pre>Doc1: &quot;Lucene powers search.&quot;<br>Doc2: &quot;Search is fast with Lucene.&quot;<br>Doc3: &quot;Lucene is written in Java.&quot;</pre><p><strong>Lucene builds this:</strong></p><pre>{<br>  &quot;lucene&quot;: [1, 2, 3],<br>  &quot;powers&quot;: [1],<br>  &quot;search&quot;: [1, 2],<br>  &quot;fast&quot;: [2],<br>  &quot;written&quot;: [3],<br>  &quot;java&quot;: [3]<br>}</pre><p>So when you search for “search”, Lucene finds it in <strong>Doc1 and Doc2</strong> — instantly.</p><h4>2. TF-IDF Scoring Algorithm</h4><p>Lucene ranks documents using <strong>Term Frequency-Inverse Document Frequency (TF-IDF)</strong>.</p><ul><li><strong>Term Frequency (TF)</strong>: How often does a word appear in a document?</li><li><strong>Inverse Document Frequency (IDF)</strong>: How rare is the word across all documents?</li></ul><p>📊 Formula:</p><pre>TF-IDF = TF(term in doc) × log(N / DF)</pre><p>Where:</p><ul><li>N = total number of documents</li><li>DF = number of documents containing the term</li></ul><p>Lucene assigns a <strong>score</strong> to each document based on this formula and <strong>sorts the results</strong> accordingly.</p><h3>🔄 Core Workflow in Lucene</h3><ol><li><strong>Indexing</strong></li></ol><ul><li>Tokenize text (break into words)</li><li>Normalize (lowercase, remove punctuation, stopwords)</li><li>Store tokens in an inverted index</li></ul><p><strong>2.Searching</strong></p><ul><li>Query terms are tokenized</li><li>Lucene retrieves matching document lists from the index</li><li>Scores documents using TF-IDF or BM25</li><li>Sorts and returns the top-k results</li></ul><h3>🧠 Key Components in Lucene</h3><p>Component Role Analyzer Breaks input text into terms (via Tokenizer and Filter) IndexWriter Writes documents into the index IndexReader Reads data from the index for searching Searcher Executes queries and returns ranked results Document A unit of searchable data (like a row) Field A key-value pair in a document</p><h3>📦 Lucene vs Elasticsearch (At a Glance)</h3><p>Feature Lucene (Core) Elasticsearch (Wrapper) Type Java library Full search engine Use case Embedded search Distributed search Storage Local Clustered (via REST API) Features Low-level, fast Full-text search + REST</p><h3>💡 Why You Should Care About Lucene</h3><ul><li>🧠 <strong>You understand how search engines work</strong> at the core level.</li><li>⚙️ <strong>You can build custom search apps</strong> without bulky external dependencies.</li><li>💾 <strong>It runs fast on local machines</strong> and embedded systems.</li><li>📚 Great for academic projects, log analysis, offline search engines, AI chat memory retrieval, etc.</li></ul><h3>📚 Resources to Learn More</h3><p><a href="https://lucene.apache.org/core/">Official Lucene Docs</a></p><p><a href="https://www.manning.com/books/lucene-in-action-second-edition">Lucene In Action Book (Manning)</a></p><p><a href="https://huggingface.co/blog/bert-as-ranker">TF-IDF vs BM25 Explained</a></p><p><a href="https://www.elastic.co/blog/found-crash-course">Elasticsearch vs Lucene Comparison</a></p><h3>🧵 Final Thoughts</h3><p>Lucene isn’t flashy like ChatGPT.<br> But it’s <strong>quietly powering the search layer</strong> of the internet.<br> And it does so with <strong>efficiency, elegance, and speed</strong>.</p><blockquote><em>Sometimes, the best tech is the one that just works — and has been for 20+ years.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e35c71617ebf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Got Selected for a Mastercard Internship: OA, Hackathon & My Full Experience]]></title>
            <link>https://medium.com/@koulvidhi2/how-i-got-selected-for-a-mastercard-internship-oa-hackathon-my-full-experience-c5da7accd343?source=rss-ce4d335e8ce4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5da7accd343</guid>
            <dc:creator><![CDATA[Vidhi koul]]></dc:creator>
            <pubDate>Sun, 25 May 2025 01:43:52 GMT</pubDate>
            <atom:updated>2025-05-25T05:55:33.051Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m thrilled to share that I’ve been selected for a <strong>Summer Internship at Mastercard</strong> through the o<strong>n-campus drive at PICT(Pune Institute of Computer Technology)</strong>. This post outlines the full journey — from the coding round to the hackathon, what I contributed, what I was asked, and what I learned.</p><p><strong>Selection Process Overview</strong></p><ol><li><strong>Online Assessment (DSA Round)</strong></li></ol><p>•⁠ <strong>⁠2 Questions:<br> 1. Graph Problem </strong><br> <strong>2.Dynamic Programming</strong><br><strong>•⁠Tested:</strong>Speed, logic, and problem-solving under pressure</p><p><strong>2.</strong> <strong>Hackathon Round</strong></p><p>•⁠ ⁠Shortlisted for hackathon post-OA<br>•⁠ ⁠Real-world problem statements from NGOs<br>•⁠ ⁠Individually judged despite team collaboration</p><p><strong>Hackathon: Building a Chatbot for Katalyst India</strong></p><p>Our team of 8, mentored by Pradeep kumar Shukla, built a chatbot solution for <strong>Katalyst NGO </strong>to automate users interaction.</p><p><strong>My Role: Frontend Developer</strong></p><p>I worked on:</p><p>•⁠ ⁠React-based chatbot interface<br>•⁠ ⁠Component structuring and routing<br>•⁠ ⁠Integrating APIs with Axios<br>•⁠ ⁠UI design using Bootstrap</p><p><strong>Key Tools:</strong> React.js, React Router, Axios, Bootstrap</p><p><strong>Evaluation Questions I Faced</strong></p><ol><li>⁠ ⁠What did you work on?</li><li>⁠What components did you create?</li><li>What React concepts did you use?</li><li>⁠How did components communicate?</li><li>⁠Which libraries and why?</li><li>Commands to create a new react page</li><li>How can you pass parameter in react and what is it called.</li><li>Explained frontend logic, data flow, and UI decisions — which helped me stand out.</li></ol><p><strong>Preparation Resources</strong></p><p><strong>📌 DSA:</strong></p><ul><li>⁠ ⁠[Striver’s DSA Sheet](<a href="https://takeuforward.org/interviews/strivers-sde-sheet-top-coding-interview-problems/">https://takeuforward.org/interviews/strivers-sde-sheet-top-coding-interview-problems/</a>)</li><li>⁠ ⁠[LeetCode](<a href="https://leetcode.com/tag/graph/">https://leetcode.com/</a>)</li><li>[Codestorywithmik] <a href="https://www.youtube.com/@codestorywithMIK">https://www.youtube.com/@codestorywithMIK</a></li></ul><p><strong>💻 Web Dev:</strong></p><ul><li>⁠ ⁠[Love Babbar — Web Dev](<a href="https://youtu.be/Vi9bxu-M-ag?si=VUNBk6giaGf9GFWl">https://youtu.be/Vi9bxu-M-ag?si=VUNBk6giaGf9GFWl</a>)<br>•⁠ ⁠[Shraddha Khapra ](<a href="https://youtu.be/l1EssrLxt7E?si=jGd8GRFRCVU9m_7J">https://youtu.be/l1EssrLxt7E?si=jGd8GRFRCVU9m_7J</a>)<br>•⁠ ⁠[Chai aur Code](<a href="https://www.youtube.com/@chaiaurcode">https://www.youtube.com/@chaiaurcode</a>)</li></ul><p><strong>Final Thoughts</strong></p><p>This opportunity was a result of consistent DSA prep, practical frontend skills, and a collaborative mindset. I’m incredibly grateful to:</p><p>•⁠ ⁠Mastercard hiring team<br>•⁠ ⁠Pradeep Kumar Shukla (Mentor)<br>•⁠ ⁠My team: Gauri, Gayatri, Devyani, Ritika, Lalit, Aman, Anish.<br>•⁠ ⁠PICT T&amp;P Cell</p><p><strong>Let’s Connect:</strong></p><p>koulvidhi2@gmail.com</p><p><a href="https://www.linkedin.com/in/vidhi-koul/">https://www.linkedin.com/in/vidhi-koul/</a></p><p>Feel free to message me for:</p><p>•⁠ ⁠Prep help<br>•⁠ ⁠Mock questions<br>•⁠ ⁠Project/code walkthroughs</p><p>#MastercardInternship #HackathonJourney #ReactJS #DSA #FrontendDeveloper #WomenInTech #PICTPune</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5da7accd343" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>