Minimum Deletions to Make String K-Special | 2 Simple Approaches | Leetcode 3085 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 30th Video of our Playlist "Greedy Technique : Popular Interview Problems".
In this video we will try to solve a very good Greedy problem : Minimum Deletions to Make String K-Special | Leetcode 3085
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 : Minimum Deletions to Make String K-Special | Simple Intuition | Leetcode 3085
Company Tags : will update soon
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Greedy/Minimum%20Deletions%20to%20Make%20String%20K-Special.cpp
Leetcode Problem Link : https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/description/
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
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 : https://www.youtube.com/@codestorywithMIK
Approach Summary :
The provided code aims to find the minimum number of deletions required from a given word such that no more than 'k' different characters remain in the word. The approach involves counting the frequency of each character in the word, sorting these frequencies, and then iterating over them.
Within each iteration, the code calculates the number of deletions required by comparing the frequency of characters with the lowest frequency encountered so far (minFreq). It then iterates over characters with higher frequencies (from 25 down to 'i') to check if the difference between their frequencies and minFreq exceeds 'k'. If so, it calculates the additional deletions required. The minimum deletions encountered in each iteration are updated in the 'result' variable, and the cumulative deletions till the current iteration are stored in 'deletedTillNow'. Finally, the minimum number of deletions found is returned as the result.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
03:56 - Approach-1 Intuition
18:30 - Approach-1 Story to code
22:51 - Approach-2 Intuition
27:24 - Approach-2 Story to code
32:29 - Coding it up
#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