Рет қаралды 9,696
Whatsapp Community Link : www.whatsapp.c...
This is the 23rd Video of our Playlist "Sliding Window : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve a good and standard Sliding Window Problem : Grumpy Bookstore Owner | Simplest Thought Process | Leetcode 1052 | codestorywithMIK
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Grumpy Bookstore Owner | Simplest Thought Process | Leetcode 1052 | codestorywithMIK
Company Tags : will update soon
My solutions on Github(C++ & JAVA) : github.com/MAZ...
Leetcode Link : leetcode.com/p...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My Recursion Concepts Playlist : • Introduction | Recursi...
My GitHub Repo for interview preparation : github.com/MAZ...
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Summary :
The approach used in the provided code to solve the problem of maximizing satisfied customers involves the following steps:
Initial Calculation:
Calculate the initial number of unsatisfied customers within the first minutes window. This is done by multiplying the number of customers by the grumpy state for the first minutes elements and summing the results.
Sliding Window Technique:
Utilize a sliding window of size minutes to determine the maximum number of unsatisfied customers that can be turned into satisfied customers by leveraging the special technique. As the window slides one position to the right:
Include the next element's contribution to unsatisfied customers if it falls within the grumpy period.
Exclude the first element of the previous window.
Update the maximum number of unsatisfied customers (maxUnsat) that can be converted to satisfied customers within any window of minutes.
Total Satisfied Customers Calculation:
Calculate the total number of satisfied customers by adding:
The maximum number of potentially converted unsatisfied customers (maxUnsat).
The customers who are already satisfied (i.e., where grumpy[i] is 0).
By combining these steps, the algorithm efficiently finds the maximum possible number of satisfied customers by utilizing a sliding window technique to optimize the period during which the special technique can be applied.
✨ Timelines✨
00:00 - Introduction
#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 #newyear2024