Apply Operations to Maximize Score | Super Detailed Approach For Beginners | Leetcode 2818 | MIK
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