<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Brajesh Lovanshi</title>
    <description>The latest articles on Forem by Brajesh Lovanshi (@br-lovanshi).</description>
    <link>https://forem.com/br-lovanshi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1054690%2F2c872380-5d66-4588-a1ac-e894dd6bc41b.jpeg</url>
      <title>Forem: Brajesh Lovanshi</title>
      <link>https://forem.com/br-lovanshi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/br-lovanshi"/>
    <language>en</language>
    <item>
      <title>New to a Large Project? This Is How I Decode Complex Databases</title>
      <dc:creator>Brajesh Lovanshi</dc:creator>
      <pubDate>Wed, 17 Dec 2025 17:08:47 +0000</pubDate>
      <link>https://forem.com/br-lovanshi/new-to-a-large-project-this-is-how-i-decode-complex-databases-422j</link>
      <guid>https://forem.com/br-lovanshi/new-to-a-large-project-this-is-how-i-decode-complex-databases-422j</guid>
      <description>&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisu77ymbu6ou9cjoamz9.jpg" alt=" " width="800" height="424"&gt;
&lt;/h2&gt;

&lt;p&gt;When you join a large-scale project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple microservices&lt;/li&gt;
&lt;li&gt;Each service has its own database&lt;/li&gt;
&lt;li&gt;Each database has dozens of tables&lt;/li&gt;
&lt;li&gt;Each table has millions of rows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a new developer or QA, the biggest struggle is:&lt;/p&gt;

&lt;p&gt;"&lt;em&gt;Where is the data coming from and how are things connected?&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;Asking others every time slows you down and reduces confidence. So here is a step-by-step approach I use to understand the database on my own.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Start From the Business Flow (Not Tables)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ask yourself what is the core business flow? (order, payment, user, inventory, etc.)&lt;br&gt;
Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Order Service → order, order_items&lt;/li&gt;
&lt;li&gt;Payment Service → payments, transactions&lt;/li&gt;
&lt;li&gt;User Service → users, addresses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;👉 This prevents random table jumping.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Identify the "Anchor Table"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In every service, there is one main table.&lt;br&gt;
Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;orders&lt;/li&gt;
&lt;li&gt;users&lt;/li&gt;
&lt;li&gt;payments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This table usually:&lt;/p&gt;

&lt;p&gt;Has id, status, created_at&lt;/p&gt;

&lt;p&gt;&lt;code&gt;DESC orders;&lt;br&gt;
SELECT * FROM orders LIMIT 10;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Use Naming Conventions to Detect Relationships&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In microservice-based Database:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Foreign keys are often not enforced&lt;/li&gt;
&lt;li&gt;Relationships are logical, not physical&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;order_id&lt;/li&gt;
&lt;li&gt;user_id&lt;/li&gt;
&lt;li&gt;payment_id&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
SELECT * FROM order_items WHERE order_id = ?;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;👉 Column names tell the story even without FK constraints.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Track Data Using Real IDs (Reverse Engineering)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pick one real record and follow it everywhere.&lt;br&gt;
Example flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Get one order_id&lt;br&gt;
Search it in:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;payments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;order_items&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;shipment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;audit tables&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM payments WHERE order_id = 123;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;👉 This builds mental mapping very fast.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Understand Status Columns Deeply&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Status columns are more important than relationships.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT DISTINCT status FROM orders;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;👉 This explains 80% of production bugs.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Read Application Code Just for Repositories/DAOs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You don't need full code understanding.&lt;br&gt;
Just search for: Repository, SQL queries, JPA entities&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Draw Your Own Simple Diagram Or Maintain Notes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No fancy tools needed.&lt;br&gt;
Just draw:&lt;br&gt;
Table names&lt;br&gt;
Arrows using *_id&lt;br&gt;
Status flow&lt;/p&gt;

&lt;p&gt;Also maintain a notes, create a small doc:&lt;br&gt;
Table name, Purpose, Important columns&lt;/p&gt;

&lt;p&gt;Even a rough diagram and notes gives huge clarity.&lt;/p&gt;

&lt;p&gt;Large MySQL databases in microservice systems look scary at first.&lt;br&gt;
But they are just well-organized business flows stored in tables.&lt;br&gt;
Hope this will help you nd add some value in your life, &lt;a href="https://www.linkedin.com/in/brajesh-lovanshi/" rel="noopener noreferrer"&gt;follow for more&lt;/a&gt;😊&lt;/p&gt;

</description>
      <category>database</category>
      <category>mysql</category>
      <category>postgres</category>
      <category>developer</category>
    </item>
    <item>
      <title>🔥 Kadane's Algorithm — The Power of Maximum Subarrays</title>
      <dc:creator>Brajesh Lovanshi</dc:creator>
      <pubDate>Thu, 17 Apr 2025 13:04:18 +0000</pubDate>
      <link>https://forem.com/br-lovanshi/kadanes-algorithm-the-power-of-maximum-subarrays-22kg</link>
      <guid>https://forem.com/br-lovanshi/kadanes-algorithm-the-power-of-maximum-subarrays-22kg</guid>
      <description>&lt;p&gt;*&lt;em&gt;Used in Amazon, Google, Microsoft Interviews 🚀&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hey devs 👋&lt;br&gt;
If you’ve ever struggled with finding the maximum sum of a subarray, this is the trick you were probably missing: &lt;strong&gt;Kadane’s Algorithm.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It’s not just smart.&lt;br&gt;
It’s ✨ interview magic ✨ — used by FAANG companies and loved by competitive programmers.&lt;/p&gt;

&lt;p&gt;**📌 What is Kadane's Algorithm?&lt;br&gt;
**Kadane’s Algorithm is a dynamic programming approach used to find the maximum sum of a contiguous subarray in linear time.&lt;/p&gt;

&lt;p&gt;_Example problem:&lt;br&gt;
_&lt;br&gt;
Given an array [-2,1,-3,4,-1,2,1,-5,4],&lt;br&gt;
Find the subarray with the maximum sum.&lt;br&gt;
Answer: [4, -1, 2, 1] with sum = 6&lt;/p&gt;

&lt;p&gt;**⚙️ How does Kadane's Algorithm work?&lt;br&gt;
**Kadane’s magic is this:&lt;br&gt;
👉 At every index, decide:&lt;/p&gt;

&lt;p&gt;Should I start a new subarray here?&lt;br&gt;
Or continue the previous one?&lt;br&gt;
You track two values:&lt;/p&gt;

&lt;p&gt;currentSum: Max sum ending at the current index&lt;br&gt;
maxSum: Global max across the array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int maxSum = nums[0];
int currentSum = nums[0];

for (int i = 1; i &amp;lt; nums.length; i++) {
    currentSum = Math.max(nums[i], currentSum + nums[i]);
    maxSum = Math.max(maxSum, currentSum);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Time Complexity: O(n)&lt;br&gt;
Space Complexity: O(1)&lt;/p&gt;

&lt;p&gt;Problem | Description&lt;br&gt;
🔗 Maximum Subarray | Classic Kadane&lt;br&gt;
🔗 Best Time to Buy and Sell Stock | Kadane twist&lt;br&gt;
🔗 Maximum Sum Circular Subarray | Kadane x2&lt;br&gt;
🔗 Maximum Product Subarray | With sign twist&lt;br&gt;
🔗 Contiguous Array | Advanced variation&lt;/p&gt;

&lt;p&gt;💡 When to Use Kadane's?&lt;br&gt;
When you need to find maximum/minimum sum of contiguous elements&lt;br&gt;
When the array has positive and negative numbers&lt;br&gt;
In profit gain, sensor data analysis, pattern detection&lt;/p&gt;

&lt;p&gt;If you like please subscribe for such more concept and follow me on linkedIn for quick learning: &lt;/p&gt;

</description>
      <category>dsa</category>
      <category>leetcode</category>
      <category>algorithms</category>
      <category>interview</category>
    </item>
    <item>
      <title>🌀 Cycle Sort: Asked in Amazon, Google, and Microsoft</title>
      <dc:creator>Brajesh Lovanshi</dc:creator>
      <pubDate>Thu, 10 Apr 2025 05:58:39 +0000</pubDate>
      <link>https://forem.com/br-lovanshi/cycle-sort-asked-in-amazon-google-and-microsoft-2l24</link>
      <guid>https://forem.com/br-lovanshi/cycle-sort-asked-in-amazon-google-and-microsoft-2l24</guid>
      <description>&lt;p&gt;Hello folks 👋,&lt;/p&gt;

&lt;p&gt;Recently, I came across Cycle Sort, and it instantly caught my attention due to its simplicity and power, especially in solving some tricky array problems. It's also been asked in interviews at Amazon, Google, and Microsoft — so it's definitely worth knowing!&lt;/p&gt;

&lt;p&gt;In this post, I'll explain Cycle Sort, when to use it, and show you some popular problems that can be solved using it.&lt;/p&gt;

&lt;p&gt;📘 What is Cycle Sort?&lt;br&gt;
Cycle Sort is a sorting algorithm that works by placing each element at its correct index in the minimum number of writes.&lt;br&gt;
It's mainly useful when you’re dealing with arrays where:&lt;/p&gt;

&lt;p&gt;All numbers are in a range (like 0 to N or 1 to N)&lt;br&gt;
The array may contain missing or duplicate values&lt;br&gt;
It is an in-place sorting algorithm with O(n) time complexity in the best case and also uses O(1) space.&lt;/p&gt;

&lt;p&gt;⏰ When to Use Cycle Sort?&lt;br&gt;
Use Cycle Sort when:&lt;/p&gt;

&lt;p&gt;You're given an array with elements from 1 to N or 0 to N&lt;br&gt;
You're solving problems related to:&lt;br&gt;
Missing numbers&lt;br&gt;
Duplicate numbers&lt;br&gt;
Correct positioning based on value&lt;br&gt;
It’s not a general-purpose sorting algorithm, but it’s perfect for certain types of interview problems.&lt;/p&gt;

&lt;p&gt;✅ Problems Solved Using Cycle Sort&lt;br&gt;
Here are some important problems you can easily solve using Cycle Sort technique:&lt;/p&gt;

&lt;p&gt;please find the problems with solutions on my GitHub :&lt;br&gt;
&lt;a href="https://github.com/br-lovanshi/Python_basic_to_advance" rel="noopener noreferrer"&gt;https://github.com/br-lovanshi/Python_basic_to_advance&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Solved Problems:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;a href="https://leetcode.com/problems/missing-number/" rel="noopener noreferrer"&gt;Missing Number (LeetCode)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;✅ &lt;a href="https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/submissions/1338369107/" rel="noopener noreferrer"&gt;Find All Numbers Disappeared in an Array&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;✅ &lt;a href="https://leetcode.com/problems/find-the-duplicate-number/" rel="noopener noreferrer"&gt;Find the Duplicate Number&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;✅ &lt;a href="https://leetcode.com/problems/first-missing-positive/description/" rel="noopener noreferrer"&gt;First Missing Positive&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;✅ &lt;a href="https://leetcode.com/problems/set-mismatch/description/" rel="noopener noreferrer"&gt;Set Mismatch&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class CycleSort {

    public static void cycleSort(int[] arr) {
        int i = 0;
        while (i &amp;lt; arr.length) {
            int correctIndex = arr[i] - 1;
            if (arr[i] != arr[correctIndex]) {
                // swap arr[i] with arr[correctIndex]
                int temp = arr[i];
                arr[i] = arr[correctIndex];
                arr[correctIndex] = temp;
            } else {
                i++;
            }
        }
    }

    public static void main(String[] args) {
        int[] nums = {3, 5, 2, 1, 4};
        cycleSort(nums);
        System.out.print("Sorted array: ");
        for (int num : nums) {
            System.out.print(num + " ");
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I’ve solved all of these using Cycle Sort, and the logic becomes very clean and easy once you understand the concept.&lt;/p&gt;

&lt;p&gt;Cycle Sort is one of those hidden gems in DSA — not commonly used in real-world sorting tasks, but incredibly powerful for specific interview questions.&lt;/p&gt;

&lt;p&gt;If you're preparing for top tech interviews, I highly recommend learning it and practicing the problems above!&lt;/p&gt;

&lt;p&gt;Let me know what you think — and feel free to share more problems where this helped you!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>algorithms</category>
      <category>programming</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
