Apply Operations to Maximize Score | Super Detailed Approach For Beginners | Leetcode 2818 | MIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=DX4zng-0pLE



Duration: 0:00
7,748 views
466


iPad PDF Link : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad PDF Notes/Leetcode-2818-.pdf
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A

Sieve Of Eratosthenes Detailed -    • Primality Check | Sieve of Eratosthen...  
Binary Exponentiation -    • Binary Exponentiation | Fast Exponent...  

Similar problem - Leetcode - 907
   • Sum of Subarray Minimums | Detailed |...  

Hi Everyone, this is the 25th video of our Playlist "Maths : Popular Interview Problems".
Now we will be solving a good Maths problem - Apply Operations to Maximize Score | Super Detailed Approach For Beginners | Leetcode 2818 | codestorywithMIK

We will start from scratch and cover everything in minute details. It might be lengthy but please see it at more speed if required.

Problem Name : Apply Operations to Maximize Score | Super Detailed Approach For Beginners | Leetcode 2818 | codestorywithMIK
Company Tags : will update later
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Mathematical/Apply Operations to Maximize Score.cpp
Leetcode Link : https://leetcode.com/problems/apply-operations-to-maximize-score/description/


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | ...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will...  
My Segment Tree Concepts Playlist :    • Segment Tree | Introduction | Basics ...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And...  
Trie Playlist -    • Word Search II (Google, Amazon, Meta,...  
Difference Array Technique: Concepts & Qns :    • Introduction | What | How | Differenc...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel :    / @codestorywithmik  

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

Video Summary :
The goal is to maximize the score by strategically selecting subarrays and multiplying elements’ powers.
The approach begins by computing the prime score of each element — which is the count of distinct prime factors of that number. To do this efficiently, we use the Sieve of Eratosthenes to precompute primes and then count prime factors for each element.
Once we have the prime scores, we use the Next Greater and Previous Greater element concepts to determine how many subarrays can be formed where each element is the maximum based on its prime score. This helps in deciding the contribution of each element.
To maximize the score, we sort the elements in descending order and greedily pick the largest elements first. For each element, we compute how many times it can be included in the score based on its subarray contribution and remaining k.
To handle large powers efficiently, we use Binary Exponentiation (Fast Power Algorithm) while multiplying to avoid overflow and keep the result within modulo.


✨ Timelines✨
00:00 - Introduction
0:33 - Motivation
1:06 - Problem Explanation
5:43 - Thought Process
10:22 - Calculating Valid Subarrays Count
28:03 - Finding NextGreater and PrevGreater
55:16 - Calculating PrimeScores
1:06:24 - Coding it up

#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hinditech #hindilearning #helpajobseeker #jobseekers #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #videomarketing #codestorywithmik #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik




Other Videos By codestorywithMIK


2025-04-10Count the Number of Powerful Integers | Detailed Thought Process | Leetcode 2999 | codestorywithMIK
2025-04-09Youtube Audio Track Feature | Change Audio Language | codestorywithMIK
2025-04-08Minimum Number of Operations to Make Elements in Array Distinct | 2 Approaches | Leetcode 3396 | MIK
2025-04-07Partition Equal Subset Sum | Recursion | Memo | Tree Diagram | Leetcode 416 | codestorywithMIK
2025-04-04Lowest Common Ancestor of Deepest Leaves | 2 Approaches | Leetcode 1123 | codestorywithMIK
2025-04-02Auto-translate the captions to any language | YouTube
2025-04-02Maximum Value of an Ordered Triplet I | Multiple Approaches | Leetcode 2873 | codestorywithMIK
2025-03-30Legends aren't defined by their successes
2025-03-30Find Median of X Sized Subarrays | Weekly Contest 443 | Hint To Qn 4 | Detailed | codestorywithMIK
2025-03-29Partition Labels | 2 Clean Approaches | Leetcode 763 | codestorywithMIK
2025-03-29Apply Operations to Maximize Score | Super Detailed Approach For Beginners | Leetcode 2818 | MIK
2025-03-28Binary Exponentiation | Fast Exponentiation | Detailed For Beginners | codestorywithMIK
2025-03-27Find the K-th Largest or Smallest in O(n) using nth_element | Competitive Programming Hack
2025-03-26Minimum Index of a Valid Split | 2 Approaches | Leetcode 2780 | codestorywithMIK
2025-03-25Minimum Operations to Make a Uni-Value Grid | Detailed Simple Maths Proof | Leetcode 2033 | MIK
2025-03-24Check if Grid can be Cut into Sections | Merge Intervals | Leetcode 3394 | Leetcode 56 | Detailed
2025-03-23Count Days Without Meetings | Simplest Explanation | Leetcode 3169 | codestorywithMIK
2025-03-22Number of Ways to Arrive at Destination | Straight Forward Simple | Leetcode 1976 | codestorywithMIK
2025-03-22Why I Will NEVER Promote Paid DSA Courses! 🚫 The Truth You Need to Know | codestorywithMIK
2025-03-21Count the Number of Complete Components | Multiple Approaches | Leetcode 2685 | codestorywithMIK
2025-03-21Find All Possible Recipes from Given Supplies | Brute Force | Optimal | Leetcode 2115