LeetCode was HARD until I Learned these 15 Patterns:
1. Prefix Sum
2. Two Pointers
3. Sliding Window
4. Fast & Slow Pointers
5. LinkedList In-place Reversal
6. Monotonic Stack
7. Top ‘K’ Elements
8. Overlapping Intervals
9. Modified Binary Search
10. Binary Tree Traversal
11.
Two months ago, I created a System Design repo on Github, and I'm excited to share that it recently reached over 3000 stars.
Thanks to everyone who has starred or forked the repository!
The repository contains a collection of resources to study:
- Around 40 System Design
I solved 1583 Leetcode problems.
But, if you don't want to solve these many problems like me, read these 13 articles:
1) 14 coding interview patterns:
2) Sliding Window Template:
3) 10-line template that can solve most
I have cleared interviews at Adobe, Amazon, Google and Microsoft.
Here are the primary resources I used for coding, system design, low level design and behavioral interviews:
After an incredible 18 months at Amazon in the US, I’ve decided to go back to India.
Today was my last day at Amazon, and I plan to leave the US in August.
It was a difficult decision to make but I want to take a break to travel, spend time with family, contribute more to open
If I had to start DSA and Leetcode from scratch, I would begin with these 15 articles to get a head start:
1) Become Master In Linked List:
2) To Queue Or Not To Queue:
3) Stacks and Overflows:
4) Taking
I Solved 1583 Leetcode Problems.
But, if you don't want to solve these many problems like me, read these 13 articles:
1) Master Linked List:
2) All types of Tree Traversals:
3) Master Recursion:
4) A
25 Concepts You Must Know for System Design Interviews:
1. Scalability:
2. Availability:
3. CAP Theorem:
4. Caching:
5. Load Balancing:
6. Rate Limiting:
How I Would Learn System Design Fundamentals (If I Had To Start Over):
📌 𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧 𝐊𝐞𝐲 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬
- Scalability:
- Latency vs Throughput:
- CAP Theorem:
- ACID Transactions:
I made a new video on: 15 𝐏𝐚𝐭𝐭𝐞𝐫𝐧𝐬 𝐭𝐡𝐚𝐭 𝐦𝐚𝐝𝐞 𝐋𝐞𝐞𝐭𝐂𝐨𝐝𝐞 𝐞𝐚𝐬𝐢𝐞𝐫 𝐟𝐨𝐫 𝐦𝐞.
For each pattern, I talk about when to use it, walk through an example and share Leetcode problems you can practice to learn it better.
Link to the video:
10 months ago, I created a System Design repo on Github, and I'm excited to share that it recently reached over 15,000 stars.
Thanks to everyone who has starred or forked this repository!
The repository contains a collection of resources to study:
- System Design concepts and
7 must-know runtime complexities for coding interviews:
1. 𝐎(1) - 𝐂𝐨𝐧𝐬𝐭𝐚𝐧𝐭 𝐭𝐢𝐦𝐞
- The runtime doesn't change regardless of the input size.
- Example: Accessing an element in an array by its index.
2. 𝐎(𝐥𝐨𝐠 𝐧) - 𝐋𝐨𝐠𝐚𝐫𝐢𝐭𝐡𝐦𝐢𝐜 𝐭𝐢𝐦𝐞
- The runtime
As a Software Engineer, it's completely fine to not know everything before the job.
Before joining Morgan Stanley, I didn't know React, Redux, Flask and Prometheus.
Before joining Amazon India, I didn't know AWS, Transformers and Typescript.
Before joining Adobe, I didn't know
My System Design repository has been trending on GitHub for the past 3 days.
It's been nearly 4 months since I created it, and I'm thrilled to see it has received over 7500 stars.
My goal with this repository is to compile the best resources for learning System Design and
If I had to start learning Data Structures and Algorithms from scratch, I would begin with these 20 articles to get a head start:
1) Time Complexity:
2) Big-O Cheat Sheet:
3) Sorting Algorithms:
4) Linked
How I Would Learn System Design (If I Had To Start Over):
📌 𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧 𝐊𝐞𝐲 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬
- Scalability:
- Latency vs Throughput:
- CAP Theorem:
- ACID Transactions:
I just finished building a GitHub repository to help you prepare for Behavioral interviews.
I've personally failed multiple behavioral interviews in past, mainly due to lack of preparation.
But with the right preparation, these interviews can be passed easily.
This repository
I just finished building a GitHub repository to learn Low Level Design (aka: LLD, Object Oriented design) and prepare for interviews.
It contains resources to study:
- Basic OOPs concepts
- SOLID principles
- Design Patterns
- UML
- Interview Problems (and solutions) categorized
15 Must-Know Patterns for Coding Interviews:
1. 𝐏𝐫𝐞𝐟𝐢𝐱 𝐒𝐮𝐦: Precomputes cumulative sums up to each index of an array.
- Used to efficiently compute range sums.
2. 𝐓𝐰𝐨 𝐏𝐨𝐢𝐧𝐭𝐞𝐫𝐬: Uses two pointers to traverse data structures.
- Used to optimize problems
My newsletter recently crossed 30,000 subscribers.
Here are the 10 most-read articles:
1. How I Mastered Data Structures and Algorithms:
2. LeetCode was HARD until I Learned these 15 Patterns:
3. System Design - What is
15 Types of Databases and When to Use Them:
1) Relational Databases (RDBMS):
- Stores data in tables with predefined schemas and relationships.
- Use for applications with structured data requiring complex queries and ACID transactions.
- Examples: MySQL, PostgreSQL, Oracle
2)
𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧: 𝐇𝐨𝐰 𝐭𝐨 𝐒𝐜𝐚𝐥𝐞 𝐚 𝐃𝐚𝐭𝐚𝐛𝐚𝐬𝐞
1. 𝐕𝐞𝐫𝐭𝐢𝐜𝐚𝐥 𝐒𝐜𝐚𝐥𝐢𝐧𝐠: Increase the power of the database server by adding more CPU, RAM, or storage to handle increased load.
2. 𝐈𝐧𝐝𝐞𝐱𝐢𝐧𝐠: Create indexes on frequently queried columns to
15 𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧 𝐓𝐫𝐚𝐝𝐞𝐨𝐟𝐟𝐬 𝐘𝐨𝐮 𝐌𝐮𝐬𝐭 𝐊𝐧𝐨𝐰:
1. 𝐒𝐜𝐚𝐥𝐚𝐛𝐢𝐥𝐢𝐭𝐲 𝐯𝐬. 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞: Grow the system to handle more work vs. execute tasks faster.
2. 𝐕𝐞𝐫𝐭𝐢𝐜𝐚𝐥 𝐯𝐬. 𝐇𝐨𝐫𝐢𝐳𝐨𝐧𝐭𝐚𝐥 𝐒𝐜𝐚𝐥𝐢𝐧𝐠: Scale up with more
10 𝐈𝐦𝐩𝐨𝐫𝐭𝐚𝐧𝐭 𝐆𝐫𝐚𝐩𝐡 𝐀𝐥𝐠𝐨𝐫𝐢𝐭𝐡𝐦𝐬 𝐟𝐨𝐫 𝐂𝐨𝐝𝐢𝐧𝐠 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰𝐬:
1. 𝐃𝐞𝐩𝐭𝐡 𝐅𝐢𝐫𝐬𝐭 𝐒𝐞𝐚𝐫𝐜𝐡 (𝐃𝐅𝐒): Explores as far as possible along each branch of a node before backtracking. Useful to explore all possible paths, detecting cycles,
10 of the Best Company Engineering Blogs I read this year:
1) How Discord stores trillions of messages:
2) Real time messaging at Slack:
3) How Canva scaled Media uploads from Zero to 50 Million per Day:
10 must read white papers if you are a Software Engineer:
1) The Google File System:
2) Dynamo: Amazon’s Highly Available Key-value Store:
3) Paxos: The Part-Time Parliament:
4) MapReduce: Simplified Data
It took me 5 years to learn these 35 coding interview lessons.
You can learn them in 5 minutes:
1) Most interviewers are on your side and want to see you perform well.
2) Prepare a short and concise introduction.
3) Be ready to discuss technical aspects of your projects in
4 GitHub repositories to help you prepare for 4 different types of Software Engineering interviews:
1. 𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰𝐬:
2. 𝐋𝐨𝐰 𝐋𝐞𝐯𝐞𝐥 𝐃𝐞𝐬𝐢𝐠𝐧 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰𝐬:
3. 𝐂𝐨𝐝𝐢𝐧𝐠
𝐒𝐐𝐋 𝐯𝐬 𝐍𝐨𝐒𝐐𝐋 - 7 𝐊𝐞𝐲 𝐃𝐢𝐟𝐟𝐞𝐫𝐞𝐧𝐜𝐞𝐬 You Must Know
1. 𝐃𝐚𝐭𝐚 𝐌𝐨𝐝𝐞𝐥
SQL: Uses a relational data model where data is stored in tables with rows and columns.
NoSQL: Offers a variety of data models including key-value, document, column-family, and graph
𝐇𝐨𝐰 𝐭𝐨 "𝐃𝐞𝐬𝐢𝐠𝐧 𝐚 𝐒𝐜𝐚𝐥𝐚𝐛𝐥𝐞 𝐍𝐨𝐭𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐒𝐞𝐫𝐯𝐢𝐜𝐞":
1. 𝐍𝐨𝐭𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐒𝐞𝐫𝐯𝐢𝐜𝐞: The Notification Service is the entry point for all notification requests. It exposes APIs that various clients can call to trigger notifications.
Added 10 new problems to the Low Level Design (LLD) GitHub repository:
𝐄𝐚𝐬𝐲:
1. Design Traffic Signal Control System
2. Design a Task Management System
𝐌𝐞𝐝𝐢𝐮𝐦:
3. Design a Digital Wallet System
4. Design an Online Auction System
5. Design a Vehicle Rental System
6.
Study these 50 Problems to ace your next System Design interview:
𝐄𝐚𝐬𝐲
1. Design URL Shortener like TinyURL
2. Design Text Storage Service like Pastebin
3. Design Content Delivery Network (CDN)
4. Design Parking Garage
5. Design Vending Machine
6. Design Distributed
15 of the most common tradeoffs in System Design:
1. 𝐒𝐜𝐚𝐥𝐚𝐛𝐢𝐥𝐢𝐭𝐲 𝐯𝐬. 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞: Grow the system to handle more work vs. execute tasks faster.
2. 𝐕𝐞𝐫𝐭𝐢𝐜𝐚𝐥 𝐯𝐬. 𝐇𝐨𝐫𝐢𝐳𝐨𝐧𝐭𝐚𝐥 𝐒𝐜𝐚𝐥𝐢𝐧𝐠: Scale up with more powerful hardware vs. scale
My Low Level Design repository is trending on GitHub today!
Currently it contains resources to study:
- Basic OOP concepts
- SOLID and other Design Principles
- Design Patterns
- UML
- 34 LLD interview problems categorized by difficulty level
In the coming months, I would be
To get better at coding, you need consistency more than you need intensity.
Intensity:
- Learn 5 programming languages.
- Solve 10 coding challenges in a day.
- Try to build multiple projects at once.
- Try to learn multiple technologies at once.
- Binge-watch coding
𝐇𝐨𝐰 𝐭𝐨 𝐀𝐧𝐬𝐰𝐞𝐫 𝐚 𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐏𝐫𝐨𝐛𝐥𝐞𝐦:
𝐒𝐭𝐞𝐩 1: 𝐂𝐥𝐚𝐫𝐢𝐟𝐲 𝐑𝐞𝐪𝐮𝐢𝐫𝐞𝐦𝐞𝐧𝐭𝐬:
𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐚𝐥 𝐑𝐞𝐪𝐮𝐢𝐫𝐞𝐦𝐞𝐧𝐭𝐬:
- What are the core features that the system should support?
- Who are the users and how
3.5 months into open-sourcing tech interview preparation.
Thanks to everyone for showing your support by starring these repositories.
If you haven't already, check them out here:
15 of the most common tradeoffs in System Design:
1. 𝐒𝐜𝐚𝐥𝐚𝐛𝐢𝐥𝐢𝐭𝐲 𝐯𝐬. 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞: Grow the system to handle more work vs. execute tasks faster.
2. 𝐕𝐞𝐫𝐭𝐢𝐜𝐚𝐥 𝐯𝐬. 𝐇𝐨𝐫𝐢𝐳𝐨𝐧𝐭𝐚𝐥 𝐒𝐜𝐚𝐥𝐢𝐧𝐠: Scale up with more powerful hardware vs. scale
15 Leetcode problems to get good at Linked List:
1) Reverse Linked List:
2) Linked List Cycle:
3) Merge Two Sorted Lists:
4) Intersection of Two Linked Lists:
5) Remove Nth Node
9 Ways to Scale a Database:
1. 𝗩𝗲𝗿𝘁𝗶𝗰𝗮𝗹 𝗦𝗰𝗮𝗹𝗶𝗻𝗴 (𝗦𝗰𝗮𝗹𝗲 𝗨𝗽): Increase the power of the database server by adding more CPU, RAM, or storage to handle increased load.
2. 𝐇𝐨𝐫𝐢𝐳𝐨𝐧𝐭𝐚𝐥 𝐒𝐜𝐚𝐥𝐢𝐧𝐠 (𝐒𝐜𝐚𝐥𝐞 𝐎𝐮𝐭): Add more database servers to
It took me 5 years to learn these 25 coding interview lessons.
You can learn them in 5 minutes:
1) Most interviewers want you to succeed.
2) Prepare a compelling introduction. Keep it short and crisp.
3) Be ready to discuss technical aspects of your projects in detail.
4)
4 Books to get better at System Design:
1. Designing Data-Intensive Applications
2. Clean Architecture
3. Building Microservices
4. Database Internals
What else you would add to this list?
***
Join 2700+ readers of my free newsletter for simple explanations to coding and
3 must read books if you are a Software Developer:
1) Clean Code
2) Head First Design Patterns
3) Designing Data-Intensive Applications
What else would you add to this list?
***
Join 14,801+ readers of my free newsletter:
S.O.L.I.D principles explained with examples:
𝐒: 𝐒𝐢𝐧𝐠𝐥𝐞 𝐑𝐞𝐬𝐩𝐨𝐧𝐬𝐢𝐛𝐢𝐥𝐢𝐭𝐲 𝐏𝐫𝐢𝐧𝐜𝐢𝐩𝐥𝐞 (𝐒𝐑𝐏)
- A class should have one, and only one, reason to change.
Example: A UserManager class that handles user authentication, user profile management, and sending
15 Leetcode problems to get good at Linked List:
1) Reverse Linked List:
2) Linked List Cycle:
3) Merge Two Sorted Lists:
4) Intersection of Two Linked Lists:
5) Remove Nth Node
My LLD GitHub repository now contains Python solutions to all interview problems.
Check it out:
Currently it contains resources to study:
- Basic OOP concepts
- SOLID and other Design Principles
- Design Patterns
- UML diagrams
- 33 LLD interview
13 Software Design Principles I wish I knew earlier:
1. 𝐂𝐨𝐦𝐩𝐨𝐬𝐢𝐭𝐢𝐨𝐧 𝐎𝐯𝐞𝐫 𝐈𝐧𝐡𝐞𝐫𝐢𝐭𝐚𝐧𝐜𝐞: Favor composing objects from smaller ones over inheriting class behavior.
2. 𝐒𝐞𝐩𝐚𝐫𝐚𝐭𝐢𝐨𝐧 𝐨𝐟 𝐂𝐨𝐧𝐜𝐞𝐫𝐧𝐬 (𝐒𝐨𝐂): Divide the system into independent
My System Design repository on Github crossed 10k stars today.
Currently it contains:
- 18 articles on System Design Key Concepts
- 26 articles on System Design Building Blocks
- How to Answer a System Design Interview Problem
- Youtube links to 50 System Design Interview
I gave 60+ coding interviews over the last 7 years.
Here are the top 10 topics they asked me:
10. Binary Search
9. Queues
8. DFS / BFS
7. Sorting
6. Sliding Window
5. Stacks
4. Linked List
3. Arrays
2. Binary Trees
1. Hash Maps
I was never asked complex Data Structures like
𝐃𝐚𝐭𝐚𝐛𝐚𝐬𝐞 𝐒𝐡𝐚𝐫𝐝𝐢𝐧𝐠 𝐞𝐱𝐩𝐥𝐚𝐢𝐧𝐞𝐝 𝐰𝐢𝐭𝐡 𝐚𝐧 𝐞𝐱𝐚𝐦𝐩𝐥𝐞:
Imagine a social media site like Instagram, which has over 1 billion active users.
Think about what would happen if it tried to keep all the user profile data on a single server.
Due to limited
10 Algorithms to Master Graphs for Coding Interviews:
1. Depth First Search (DFS)
2. Breadth First Search (BFS)
3. Topological Sort
4. Union Find
5. Cycle Detection
6. Connected Components
7. Bipartite Graphs
8. Flood Fill
9. Minimum Spanning Tree
10. Shortest Path
I wrote a
You need consistency more than you need intensity to get better at coding.
Intensity:
- Learn 5 programming languages.
- Solve 10 coding challenges in a day.
- Try to build multiple projects at once.
- Try to learn multiple technologies at once.
- Binge-watch coding
I published a new System Design interview problem on my blog: Design a Distributed Job Scheduler
Read it here:
Subscribe for more such articles every week.
I wrote a new article on: How I Setup my Terminal for Productivity
It contains step-by-step instructions, commands, tools and shortcuts to supercharge your terminal experience.
Read it here:
Consider subscribing for more such content every week.
𝐒𝐲𝐬𝐭𝐞𝐦 𝐃𝐞𝐬𝐢𝐠𝐧: 10 𝐖𝐚𝐲𝐬 𝐭𝐨 𝐒𝐜𝐚𝐥𝐞 𝐚 𝐒𝐲𝐬𝐭𝐞𝐦
1. 𝐕𝐞𝐫𝐭𝐢𝐜𝐚𝐥 𝐒𝐜𝐚𝐥𝐢𝐧𝐠: Add more power to your existing machines by upgrading it with more RAM, faster CPUs, or additional storage.
2. 𝐇𝐨𝐫𝐢𝐳𝐨𝐧𝐭𝐚𝐥 𝐒𝐜𝐚𝐥𝐢𝐧𝐠: Add more machines to
𝐒𝐨𝐟𝐭𝐰𝐚𝐫𝐞 𝐃𝐞𝐬𝐢𝐠𝐧 𝐏𝐫𝐢𝐧𝐜𝐢𝐩𝐥𝐞𝐬 𝐄𝐯𝐞𝐫𝐲 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫 𝐒𝐡𝐨𝐮𝐥𝐝 𝐊𝐧𝐨𝐰:
1. You Aren't Gonna Need It (YAGNI)
2. Don't Repeat Yourself (DRY)
3. Keep It Simple, Stupid (KISS)
4. Encapsulate What Varies
5. Program to an Interface, Not an
First step in a System Design interview is to understand the problem and clarify requirements.
Here are the example questions you can ask to clarify 𝐟𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐚𝐥 and 𝐧𝐨𝐧-𝐟𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐚𝐥 requirements:
𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐚𝐥 𝐫𝐞𝐪𝐮𝐢𝐫𝐞𝐦𝐞𝐧𝐭𝐬:
- What are the
I made a new video on: 𝐇𝐨𝐰 𝐈 𝐌𝐚𝐬𝐭𝐞𝐫𝐞𝐝 𝐃𝐚𝐭𝐚 𝐒𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞𝐬 𝐚𝐧𝐝 𝐀𝐥𝐠𝐨𝐫𝐢𝐭𝐡𝐦𝐬.
It's a 10:45 minutes video where I talk about:
- Must-Know DSA topics
- An order you can follow to learn DSA topics
- How to start learning a new topic?
- Resources I
Git commands I used 99% of the time being a Software Developer for 6+ years:
1. 𝐠𝐢𝐭 𝐝𝐢𝐟𝐟: Show file differences not yet staged.
2. 𝐠𝐢𝐭 𝐜𝐨𝐦𝐦𝐢𝐭 -𝐚 -𝐦 "𝐜𝐨𝐦𝐦𝐢𝐭 𝐦𝐞𝐬𝐬𝐚𝐠𝐞": Commit all tracked changes with a message.
3. 𝐠𝐢𝐭 𝐬𝐭𝐚𝐭𝐮𝐬: Show the state
10 must-read Company Engineering Blogs to get better at real world System Design:
1) How Discord stores trillions of messages:
2) Real time messaging at Slack:
3) How Canva scaled Media uploads from Zero to 50 Million per Day:
I made a new video on: How to Master System Design for Interviews (as a beginner)
It’s a 10 minutes video where I talk about:
1. What System Design actually is?
2. How to Start Learning System Design?
3. What Concepts You Need to Know?
4. How to Prepare for System Design
Scalability is one of the most important concepts in System Design.
Here is a short masterclass to learn it:
Running a system for one user is significantly different from running it for 10,000 users and that too is different from running it for 1 million users.
As the system
Programming Principles they don't teach you in college:
1) DRY Principle: Don't Repeat Yourself.
2) KISS Principle: Keep it Simple Stupid.
3) YAGNI Principle: You Aren't Gonna Need It.
4) SOLID Principles
↳ S — Single Responsibility
↳ O — Open/Closed
↳ L — Liskov
15 Different Types of Databases and When to Use Them:
1) Relational Databases (RDBMS):
- Stores data in tables with predefined schemas and relationships.
- Use for applications with structured data requiring complex queries and ACID transactions.
- Examples: MySQL, PostgreSQL,
If you want to learn about 𝐥𝐨𝐚𝐝 𝐛𝐚𝐥𝐚𝐧𝐜𝐢𝐧𝐠 𝐚𝐥𝐠𝐨𝐫𝐢𝐭𝐡𝐦𝐬 𝐚𝐧𝐝 𝐡𝐨𝐰 𝐭𝐨 𝐢𝐦𝐩𝐥𝐞𝐦𝐞𝐧𝐭 𝐭𝐡𝐞𝐦 𝐢𝐧 𝐜𝐨𝐝𝐞, checkout my new article:
Subscribe for more such articles every week:
𝐖𝐡𝐚𝐭 𝐚𝐫𝐞 𝐖𝐞𝐛𝐬𝐨𝐜𝐤𝐞𝐭𝐬 𝐚𝐧𝐝 𝐰𝐡𝐞𝐫𝐞 𝐚𝐫𝐞 𝐭𝐡𝐞𝐲 𝐮𝐬𝐞𝐝?
WebSockets are a protocol that enables full-duplex, bidirectional communication between a client (typically a web browser) and a server over a single TCP connection.
Unlike the traditional HTTP
𝐂𝐨𝐝𝐢𝐧𝐠 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐏𝐚𝐭𝐭𝐞𝐫𝐧 - 𝐏𝐫𝐞𝐟𝐢𝐱 𝐒𝐮𝐦
Prefix Sum pattern involves preprocessing an array to create a new array (prefix array) where each element at index i represents the sum of the array from the start up to i.
In other words: 𝐏[𝐢] = 𝐀[0] +