question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
k-diff-pairs-in-an-array
C++ solution | binary search | sorting | O(n)
c-solution-binary-search-sorting-on-by-r-wxo8
\nint findPairs(vector<int>& nums, int k)\n{\n sort(nums.begin(), nums.end());\n int count = 0;\n for (int i = 0; i < nums.size(); i++)\n {\n
rajnishgeek
NORMAL
2021-08-16T12:26:50.888713+00:00
2021-08-16T12:26:50.888778+00:00
241
false
```\nint findPairs(vector<int>& nums, int k)\n{\n sort(nums.begin(), nums.end());\n int count = 0;\n for (int i = 0; i < nums.size(); i++)\n {\n if (i > 0 && i < nums.size() && nums[i - 1] == nums[i])\n {\n while (i < nums.size() && nums[i - 1] == nums[i])\n i++;\n ...
3
3
['Binary Search']
1
k-diff-pairs-in-an-array
C++ O(n) soln
c-on-soln-by-aditya0753-9bx3
\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n int n=nums.size();\n unordered_map<int,int> m;\n int c=0;\n
aditya0753
NORMAL
2021-08-07T03:28:27.498887+00:00
2021-08-07T03:28:27.498915+00:00
347
false
```\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n int n=nums.size();\n unordered_map<int,int> m;\n int c=0;\n \n if(k<0) return 0;\n \n for(int i=0;i<n;i++){\n m[nums[i]]++;\n }\n \n if(k==0){\n for...
3
0
[]
1
k-diff-pairs-in-an-array
[C++] Simple single loop approach
c-simple-single-loop-approach-by-ritik30-xyce
\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n unordered_map<int,int> freq;\n for(int i=0;i<nums.size();i++){\n
ritik307
NORMAL
2021-07-14T18:51:44.581141+00:00
2021-07-14T18:51:44.581165+00:00
504
false
```\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n unordered_map<int,int> freq;\n for(int i=0;i<nums.size();i++){\n freq[nums[i]]++;\n }\n int count=0;\n if(k!=0){\n for(auto itr:freq){\n if(freq.find(itr.first+k)!=freq...
3
0
['Hash Table', 'C', 'C++']
0
k-diff-pairs-in-an-array
Cpp Solution beats 100% - O(nlogn) Two Pointer Approach [ proof attached ;) ]
cpp-solution-beats-100-onlogn-two-pointe-8c1f
Hello World !!. A two pointer based approach. Code is commented for better understanding. Hope it helps otherwise feel free to comment. \nThanks.\nHappy Coding
zeroAadi
NORMAL
2021-06-26T08:51:31.623609+00:00
2021-07-11T05:21:39.245607+00:00
262
false
Hello World !!. A two pointer based approach. Code is commented for better understanding. Hope it helps otherwise feel free to comment. \nThanks.\nHappy Coding.\n```\n int n=nums.size();\n\t \n\t // Sort the given vector\n sort(nums.begin(),nums.end());\n int i=0;\n int j=1;\n int c=0; ...
3
1
[]
1
k-diff-pairs-in-an-array
Easy C++ Soln || nlogn || One pointer with Binary Search
easy-c-soln-nlogn-one-pointer-with-binar-x5um
\nclass Solution {\npublic:\n //one pointer with binary search nlogn\n int findPairs(vector<int>& nums, int k) {\n int ans=0;\n sort(nums.be
mitedyna
NORMAL
2021-05-24T21:58:46.854304+00:00
2021-05-24T21:58:46.854334+00:00
292
false
```\nclass Solution {\npublic:\n //one pointer with binary search nlogn\n int findPairs(vector<int>& nums, int k) {\n int ans=0;\n sort(nums.begin(),nums.end());\n for(int i=0;i<nums.size()-1;i++){\n if(i>0 && nums[i]==nums[i-1])continue;\n int x=nums[i];\n in...
3
0
['C', 'Binary Tree']
0
k-diff-pairs-in-an-array
C++ || Simple easy solution || Two pointer technique
c-simple-easy-solution-two-pointer-techn-m5tz
\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n int n=nums.size();\n sort(nums.begin(),nums.end());\n int count
akanksha_06
NORMAL
2021-05-23T07:42:20.244377+00:00
2021-05-23T07:42:20.244425+00:00
214
false
```\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n int n=nums.size();\n sort(nums.begin(),nums.end());\n int count=0;\n int i=0;\n int j=1;\n while(i<n && j<n)\n {\n if(i!=j && nums[j]-nums[i]==k){\n while(i+1 < n && ...
3
1
['Two Pointers', 'C']
0
k-diff-pairs-in-an-array
C++ solution using set and hashmap. TC - O(nlogn) and SC - O(n)
c-solution-using-set-and-hashmap-tc-onlo-wdbw
\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n unordered_map<int,int> mp;\n \n int s = nums.size();\n
sumit_code
NORMAL
2021-04-17T04:38:21.912573+00:00
2021-04-17T04:38:21.912604+00:00
365
false
```\nclass Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n unordered_map<int,int> mp;\n \n int s = nums.size();\n \n for(int i=0;i<s;i++)\n mp[nums[i]] = i;\n \n \n int res = 0;\n \n set<pair<int,int>> st;\n \n ...
3
1
['C', 'Ordered Set']
1
minimum-deletions-to-make-string-k-special
[Java/C++/Python] Enumerate Minimum Frequency
javacpython-enumerate-minimum-frequency-038ab
Intuition\nFirst, we need to calculate character frequencies.\nwe delete characters for two reasons:\n1. Delete the small frequency to zero, so it doesn\'t coun
lee215
NORMAL
2024-03-17T04:09:32.411228+00:00
2024-03-17T07:38:17.504122+00:00
3,176
false
# **Intuition**\nFirst, we need to calculate character frequencies.\nwe delete characters for two reasons:\n1. Delete the small frequency to zero, so it doesn\'t count for the rule.\n2. Delete the big frequency smaller, so it `big freq - small freq <= k`.\nAnd we won\'t reduce small freq to smaller positive.\n<br>\n\n#...
57
1
['C', 'Python', 'Java']
18
minimum-deletions-to-make-string-k-special
Explained - using simple freq check
explained-using-simple-freq-check-by-kre-kh7f
Approach\n- Find the frequency of each of the characters in word\n- Sort the freq array\n- Consider each of the freq as the minFreq possible and with this consi
kreakEmp
NORMAL
2024-03-17T04:02:18.060816+00:00
2024-03-17T05:09:08.157531+00:00
5,706
false
# Approach\n- Find the frequency of each of the characters in word\n- Sort the freq array\n- Consider each of the freq as the minFreq possible and with this consideration we need to evaluate how many char from the higher frequency to be deleted to get the condition satisfied for all freq\n- Consider the next frequency ...
34
0
['C++']
9
minimum-deletions-to-make-string-k-special
Simple Hashing || Consider All Possibilities
simple-hashing-consider-all-possibilitie-ws58
# Intuition \n\n\n# Approach\n1. Initialize an unordered map mp to store the frequency of each character in the word.\n2. Iterate through the characters in th
AdityaRaj_cpp
NORMAL
2024-03-17T04:02:01.092233+00:00
2024-03-17T04:02:01.092261+00:00
2,990
false
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Initialize an unordered map mp to store the frequency of each character in the word.\n2. Iterate through the characters in the word and update the frequency in the map.\n3. Create a vector v to store the frequenc...
29
1
['Hash Table', 'Sorting', 'C++']
7
minimum-deletions-to-make-string-k-special
C++||With explanation
cwith-explanation-by-baibhavkr143-w5sc
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
baibhavkr143
NORMAL
2024-03-17T04:00:46.049068+00:00
2024-03-17T04:07:15.792122+00:00
1,532
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
15
1
['C++']
4
minimum-deletions-to-make-string-k-special
Simple java solution
simple-java-solution-by-siddhant_1602-nps2
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\n public int minimumDeletions(String word, int k) {\n in
Siddhant_1602
NORMAL
2024-03-17T04:02:39.059413+00:00
2024-03-17T04:02:39.059446+00:00
816
false
# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int a[]=new int[26];\n for(char c:word.toCharArray())\n {\n a[c-\'a\']++;\n }\n Arrays.sort(a);\n List<...
14
0
['Java']
1
minimum-deletions-to-make-string-k-special
Python 3 || 7 lines, Counter || T/S: 98% / 29%
python-3-7-lines-counter-ts-98-29-by-spa-s5dn
Here\'s the plan:\n\n\n1. We use Counter to determine the counts of the characters as the list vals.\n\n1. We construct a function minimumDeletions that, given
Spaulding_
NORMAL
2024-03-17T20:07:49.067850+00:00
2024-05-24T20:15:43.657009+00:00
313
false
Here\'s the plan:\n\n\n1. We use `Counter` to determine the counts of the characters as the list `vals`.\n\n1. We construct a function `minimumDeletions` that, given a range [*num... num+k*], determines the minimum count of deletions to ensure that character counts remaining after these deletions are in that interval....
9
0
['Python3']
2
minimum-deletions-to-make-string-k-special
Easy C++ Solution using Dynamic Programming and Sorting
easy-c-solution-using-dynamic-programmin-gavh
Intuition\nThe problem requires finding the minimum number of characters needed to delete from a string to make it k-special. A string is considered k-special i
vanshwari
NORMAL
2024-03-17T04:03:17.198623+00:00
2024-04-03T05:51:53.683977+00:00
549
false
# Intuition\nThe problem requires finding the minimum number of characters needed to delete from a string to make it k-special. A string is considered k-special if the absolute difference in frequencies of any two characters in the string is less than or equal to k.\n\n# Approach\n1. Count the frequencies of each chara...
9
0
['C++']
1
minimum-deletions-to-make-string-k-special
C++ 100% Faster | Easy Step By Step Explanation
c-100-faster-easy-step-by-step-explanati-brnt
Intuition\nThe key to solve this problem lies in identifying the discrepancies between character frequencies. A string is k-special if the absolute difference b
VYOM_GOYAL
NORMAL
2024-03-17T04:00:46.362211+00:00
2024-03-18T01:39:33.640927+00:00
860
false
# Intuition\nThe key to solve this problem lies in identifying the discrepancies between character frequencies. A string is k-special if the absolute difference between the frequencies of any two characters (|freq(i) - freq(j)|) is less than or equal to k. Therefore, we need to find the minimum number of deletions requ...
8
1
['Array', 'Math', 'C++']
2
minimum-deletions-to-make-string-k-special
Python Easy Solution
python-easy-solution-by-shree_govind_jee-y5l6
Code\nJava\n\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int[] freq = new int[26];\n for(char ch:word.toCharArray()
Shree_Govind_Jee
NORMAL
2024-03-17T04:04:20.333307+00:00
2024-03-17T04:04:20.333335+00:00
781
false
# Code\n**Java**\n```\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int[] freq = new int[26];\n for(char ch:word.toCharArray()){\n freq[ch-\'a\']++;\n }\n \n// Sorted in Increasing order\n Arrays.sort(freq);\n int min_del = Intege...
7
0
['Array', 'Python', 'Python3']
3
minimum-deletions-to-make-string-k-special
Dynamic Programming Easy to Understand Solution
dynamic-programming-easy-to-understand-s-tmj7
Intuition\nThe function f is recursively called to find the minimum number of deletions required. It considers the leftmost and rightmost characters \nIf the di
asitvts
NORMAL
2024-03-17T04:30:14.007159+00:00
2024-03-17T04:30:14.007177+00:00
390
false
# Intuition\nThe function f is recursively called to find the minimum number of deletions required. It considers the leftmost and rightmost characters \nIf the difference between their frequencies is less equal to k, no need to check further.\nElse perform deletion\nDeletion can be done in two different ways\n- Either ...
6
0
['Dynamic Programming', 'Sorting', 'C++']
0
minimum-deletions-to-make-string-k-special
Easy to Understand O(N) TC and O(1) SC Beats 100%
easy-to-understand-on-tc-and-o1-sc-beats-yogf
https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/submissions/1206029598/\n# Intuition\n Describe your first thoughts on how to solve thi
sainadth
NORMAL
2024-03-17T06:13:53.920826+00:00
2024-03-17T10:51:27.294504+00:00
283
false
[https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/submissions/1206029598/]()\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIntution is to select a non zero frequency and make all the other frequencies to be in the range of `[frequency, frequency + k]`\n# Appr...
5
0
['C++']
1
minimum-deletions-to-make-string-k-special
[Python3] DFS + Backtracking
python3-dfs-backtracking-by-dolong2110-xtre
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
dolong2110
NORMAL
2024-03-17T04:05:05.493830+00:00
2024-03-17T14:57:55.505353+00:00
311
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
5
0
['Python3']
0
minimum-deletions-to-make-string-k-special
Simple C++ solution, very intuitive
simple-c-solution-very-intuitive-by-fell-hfpr
Intuition\n Describe your first thoughts on how to solve this problem. \nAt the beginning the problem seems a little bit scary, infact it tells us to consider a
Felle33
NORMAL
2024-03-17T20:24:25.951043+00:00
2024-03-17T20:25:39.717850+00:00
316
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAt the beginning the problem seems a little bit scary, infact it tells us to consider all the pairwise indeces and confront them.\nIn reality we don\'t have to confront all the possible indeces, but just the letters.\n\n**The main intuiti...
4
0
['String', 'Greedy', 'C++']
1
minimum-deletions-to-make-string-k-special
Short explanation + Comments || 87ms Solution || Using 2-Dimensional DP || O(N) time and O(1) space
short-explanation-comments-87ms-solution-mw95
Approach\n Describe your approach to solving the problem. \nFirst, calculate frequencies of all the characters.\n\nObservation - For each pair of indices in the
neil_paul
NORMAL
2024-03-17T06:45:19.936798+00:00
2024-03-17T06:47:00.336053+00:00
146
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst, calculate frequencies of all the characters.\n\nObservation - For each pair of indices in the frequency array, we can either delete all characters of the lower frequency, or reduce just enough characters of the higher frequency as to make their...
4
0
['Python3']
2
minimum-deletions-to-make-string-k-special
Binary Search || Prefix Sum || nlog(n) solution || Iterate over all possible values as the minimum
binary-search-prefix-sum-nlogn-solution-gm8u8
Intuition\n Describe your first thoughts on how to solve this problem. \n\nAfter computing the frequency of characters in the string, we can convert the problem
hliu4
NORMAL
2024-03-17T04:24:43.097857+00:00
2024-03-17T23:18:50.275409+00:00
434
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nAfter computing the frequency of characters in the string, we can convert the problem to the following:\n\nGiven an array nums and an integer k, find the minimum number of operations to make |nums[i] - nums[j]| <= k for any pair of i an...
4
0
['Binary Search', 'Prefix Sum', 'Java']
0
minimum-deletions-to-make-string-k-special
Java Clean Solution || Weekly Contest
java-clean-solution-weekly-contest-by-sh-flki
Complexity\n- Time complexity:O(n+Soting + 26*26)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(26)\n Add your space complexity here, e.g.
Shree_Govind_Jee
NORMAL
2024-03-17T04:03:03.470518+00:00
2024-03-17T04:03:03.470561+00:00
454
false
# Complexity\n- Time complexity:$$O(n+Soting + 26*26)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(26)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int[] freq = new int[26]...
4
0
['Array', 'Python', 'Java', 'Python3']
2
minimum-deletions-to-make-string-k-special
Beats 💯% of all other | Beginner Friendly✅
beats-of-all-other-beginner-friendly-by-0gexr
Intuition\n\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n- Create a freq map for every charecter\n- Sort the value of each cha
viresh_dev
NORMAL
2024-03-17T05:22:50.420348+00:00
2024-03-17T05:22:50.420382+00:00
180
false
# Intuition\n![Screenshot 2024-03-17 104545.png](https://assets.leetcode.com/users/images/5c9bde90-8ea0-4755-adfa-65a35d4c2f79_1710652630.1537528.png)\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- Create a freq map for every charecter\n- Sort the value of each charecter\n- chec...
3
0
['Array', 'Hash Table', 'Greedy', 'Sorting', 'Python3']
2
minimum-deletions-to-make-string-k-special
Easy Java Solution
easy-java-solution-by-mayur0106-oyas
\n# Code\n\n\nclass Solution {\n public int minimumDeletions(String word, int k) {\n \n // store the frequency of the character\n Intege
mayur0106
NORMAL
2024-03-17T04:14:43.765684+00:00
2024-03-17T04:14:43.765712+00:00
249
false
\n# Code\n```\n\nclass Solution {\n public int minimumDeletions(String word, int k) {\n \n // store the frequency of the character\n Integer []arr=new Integer[26];\n for(int i=0;i<arr.length;i++) {\n arr[i]=0;\n }\n for(int i=0;i<word.length();i++)\n {\n ...
3
0
['Java']
0
minimum-deletions-to-make-string-k-special
🔥 [CPP] | Freq Array (Max Freq)
cpp-freq-array-max-freq-by-rushi_mungse-cwgx
\n\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int max_freq = 0;\n vector<int> freq(26);\n for(auto &w :
rushi_mungse
NORMAL
2024-03-17T04:01:12.098681+00:00
2024-03-17T04:01:12.098730+00:00
369
false
\n\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int max_freq = 0;\n vector<int> freq(26);\n for(auto &w : word) max_freq = max(max_freq, ++freq[w - \'a\']);\n \n int ans = INT_MAX;\n for(int make = 0; make <= max_freq; make++) {\n ...
3
0
['C++']
1
minimum-deletions-to-make-string-k-special
Very easy DP Code || Intuitive || Explained
very-easy-dp-code-intuitive-explained-by-bvjb
Complexity\n- Time complexity: O(n + 2626) \n\n- Space complexity: O(2626) \n\n# Code\n\nclass Solution {\n int solve(int i, int j, int k, vector<int>& arr,
coder_rastogi_21
NORMAL
2024-03-20T15:03:39.051381+00:00
2024-03-20T15:03:39.051414+00:00
18
false
# Complexity\n- Time complexity: $$O(n + 26*26)$$ \n\n- Space complexity: $$O(26*26)$$ \n\n# Code\n```\nclass Solution {\n int solve(int i, int j, int k, vector<int>& arr, vector<vector<int>>& dp)\n {\n if(i == j || arr[j] - arr[i] <= k) //base case\n return 0;\n \n if(dp[i][j] != ...
2
0
['Dynamic Programming', 'C++']
0
minimum-deletions-to-make-string-k-special
Easy HashMap Java Solution
easy-hashmap-java-solution-by-deep_ptl-5xqo
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n\n1) Initialize a HashMap freqMap to store the frequency of each characte
deep_ptl
NORMAL
2024-03-17T22:14:47.101314+00:00
2024-03-17T22:14:47.101344+00:00
43
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n\n1) Initialize a HashMap freqMap to store the frequency of each character in the word.\n2) Iterate through each character in the input word and update the frequency count in the freqMap.\n3) For each character c in the word...
2
0
['Array', 'Hash Table', 'Java']
0
minimum-deletions-to-make-string-k-special
DP | Alternative Approach | C++
dp-alternative-approach-c-by-sparker_724-qji2
It can be solved with simple brute force iteration. Here is an alternative approach whic uses basic dynamic programming\n# Intuition\nFor any two numbers of the
Sparker_7242
NORMAL
2024-03-17T08:08:31.923455+00:00
2024-03-17T08:08:31.923474+00:00
29
false
It can be solved with simple brute force iteration. Here is an alternative approach whic uses basic dynamic programming\n# Intuition\nFor any two numbers of the frequency array, there are two possibilities - either remove the smaller one or decrease the larger one.\n\n\n# Approach\nWrite a recursive code for the two by...
2
0
['C++']
0
minimum-deletions-to-make-string-k-special
Video Explanation (Along with a HARDER VERSION)
video-explanation-along-with-a-harder-ve-qwzx
Explanation \n\nClick here for the video\n\n# Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n vector<int> frq(26);\n
codingmohan
NORMAL
2024-03-17T05:47:04.168850+00:00
2024-03-17T05:47:04.168883+00:00
93
false
# Explanation \n\n[Click here for the video](https://youtu.be/NAWNz8caFK8)\n\n# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n vector<int> frq(26);\n for (auto c : word) frq[c-\'a\'] ++; \n \n int ans = 1e5;\n \n for (int l = 1; l <= ...
2
0
['C++']
0
minimum-deletions-to-make-string-k-special
Intuitive recursion-based, whether to delete the least frequency one or keep it.
intuitive-recursion-based-whether-to-del-8leb
Intuition\nAfter sorting by the frequencies in descrending order, recursively consider keeping the letter with the least frequency or delete it.\n\n# Approach\n
practice_harder
NORMAL
2024-03-17T04:17:29.684662+00:00
2024-03-17T06:43:06.507679+00:00
300
false
# Intuition\nAfter sorting by the frequencies in descrending order, recursively consider keeping the letter with the least frequency or delete it.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Count the frequencies for 26 letters\n2. Sort the frequencies in descrending order\n3. Two ways to...
2
0
['C++']
0
minimum-deletions-to-make-string-k-special
Only Using Map Explained ✅✔️
only-using-map-explained-by-nandunk-mgnw
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
nandunk
NORMAL
2024-03-17T04:08:38.364062+00:00
2024-03-17T04:08:38.364113+00:00
477
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
minimum-deletions-to-make-string-k-special
[Java Solution] Dynamic Programming With Clear Explanation
java-solution-dynamic-programming-with-c-a0lb
Intuition\nThe challenge involves balancing the frequencies of characters in a string to make it "k-special," where the frequency difference between any two cha
trtdytr
NORMAL
2024-03-17T04:07:40.509011+00:00
2024-03-17T04:37:48.725879+00:00
111
false
# Intuition\nThe challenge involves balancing the frequencies of characters in a string to make it "k-special," where the frequency difference between any two characters does not exceed `k`. The initial step is to understand the frequency distribution of characters, guiding the deletions needed to achieve this balance....
2
0
['Dynamic Programming', 'Java']
1
minimum-deletions-to-make-string-k-special
O(n) Solution | Rust
on-solution-rust-by-prog_jacob-kuch
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
Prog_Jacob
NORMAL
2024-03-17T04:05:04.440808+00:00
2024-03-17T16:30:42.275672+00:00
15
false
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimpl Solution {\n pub fn minimum_deletions(word: String, k: i32) -> i32 {\n let mut map = [0; 26];\n l...
2
0
['Rust']
0
minimum-deletions-to-make-string-k-special
check all ranges from 0 to k to (maxfreq - k) to (maxfreq)
check-all-ranges-from-0-to-k-to-maxfreq-qizje
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
batman654
NORMAL
2024-03-17T04:04:04.377691+00:00
2024-03-17T04:35:35.081055+00:00
130
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
minimum-deletions-to-make-string-k-special
Hasp Map Solution
hasp-map-solution-by-tlecodes-xbxg
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
tlecodes
NORMAL
2024-10-08T11:46:18.983050+00:00
2024-10-08T11:46:18.983067+00:00
8
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
0
minimum-deletions-to-make-string-k-special
[Python] count freq
python-count-freq-by-pbelskiy-9h5b
\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n\n @cache\n def dfs(left, right):\n d = a[right] - a[left
pbelskiy
NORMAL
2024-03-23T14:43:14.540076+00:00
2024-03-23T14:43:14.540093+00:00
6
false
```\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n\n @cache\n def dfs(left, right):\n d = a[right] - a[left]\n if d <= k:\n return 0\n\n return min(\n dfs(left + 1, right) + a[left], # remove\n df...
1
0
['Python']
0
minimum-deletions-to-make-string-k-special
Leelavardhan's Java Solution 5ms
leelavardhans-java-solution-5ms-by-klu_2-79h1
Intuition\n Describe your first thoughts on how to solve this problem. \n Calculate the frequency of each Character and store them into a array and do sort and
klu_2200031318
NORMAL
2024-03-23T11:02:29.342672+00:00
2024-03-23T11:02:29.342702+00:00
51
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n Calculate the frequency of each Character and store them into a array and do sort and follow the approach.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe question is about to delete minimum characters so that...
1
0
['Java']
0
minimum-deletions-to-make-string-k-special
[C++ / Go] Sliding Window - O(n) time / O(26) space solution
c-go-sliding-window-on-time-o26-space-so-c03i
Approach\n- Count the number of occurrences of each character and then sort them in ascending order.\n- Iterate l through the counting array cnt:\n - Maintai
mikazuki4712
NORMAL
2024-03-19T17:05:12.931445+00:00
2024-03-19T17:05:12.931482+00:00
39
false
# Approach\n- Count the number of occurrences of each character and then sort them in ascending order.\n- Iterate `l` through the counting array `cnt`:\n - Maintain a sliding window with 2 ends `l` and `r`, where `cnt[r] - cnt[l] <= k` and `r` is maximum.\n - Here we perform deletions to ensure that all occurrenc...
1
0
['Sliding Window', 'C++', 'Go']
0
minimum-deletions-to-make-string-k-special
7 Line Dynamic Programming Solution using Counter, O(n) runtime.
7-line-dynamic-programming-solution-usin-psnk
I and J are restricted by O(26) for each since there is 26 char in the alphabet. So our runtime is O(n) from len(word) = n and spacetime is O(26 * 26) ~ O(1). \
robert961
NORMAL
2024-03-18T19:38:37.544522+00:00
2024-03-18T19:38:37.544552+00:00
46
false
I and J are restricted by O(26) for each since there is 26 char in the alphabet. So our runtime is O(n) from len(word) = n and spacetime is O(26 * 26) ~ O(1). \n# Code\n```\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n cnt = Counter(word)\n c = deque(sorted(list(cnt.values(...
1
0
['Dynamic Programming', 'Python3']
0
minimum-deletions-to-make-string-k-special
Recursive C++ Solution
recursive-c-solution-by-anupsingh556-q3hb
Intuition\n- sort frequency array in descending order\n- we can either reduce minimum freq to 0 or make max freq to min(freq) + k\n- use recursion to find minim
anupsingh556
NORMAL
2024-03-18T09:07:36.673589+00:00
2024-03-18T09:07:36.673615+00:00
8
false
# Intuition\n- sort frequency array in descending order\n- we can either reduce minimum freq to 0 or make max freq to min(freq) + k\n- use recursion to find minimum from both operations\n\n# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n vector<int> freq(26, 0);\n f...
1
0
['C++']
0
minimum-deletions-to-make-string-k-special
Easy C++ solution | Beats 100% solutions
easy-c-solution-beats-100-solutions-by-a-j2a2
Intuition\nCalculate the frequencies of all characters in the string. Since we can only delete a character (that is reduce the frequency of character), we can l
ankitjangir001
NORMAL
2024-03-18T04:21:17.919380+00:00
2024-03-18T04:21:17.919425+00:00
48
false
# Intuition\nCalculate the frequencies of all characters in the string. Since we can only delete a character (that is reduce the frequency of character), we can loop for all frequencies of chars keeping an `target` value and adjusting all frequencies suitable to that `target`. If for a `target`, the freq of char is les...
1
0
['C++']
0
minimum-deletions-to-make-string-k-special
Simple python3 solution | 85 ms - faster than 100.00% solutions
simple-python3-solution-85-ms-faster-tha-xyzq
Complexity\n- Time complexity: O(n + m) = O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(m) = O(1)\n Add your space complexity here,
tigprog
NORMAL
2024-03-17T23:17:25.778171+00:00
2024-03-17T23:17:25.778207+00:00
161
false
# Complexity\n- Time complexity: $$O(n + m) = O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(m) = O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\nwhere `m = 26` - number of lowercase English letters\n\n# Code\n``` python3 []\nclass Solution:\n def minimumDe...
1
0
['Two Pointers', 'Sliding Window', 'Sorting', 'Counting', 'Python3']
0
minimum-deletions-to-make-string-k-special
⚡Greedy || 🌟Sorting || 🔥HashMap
greedy-sorting-hashmap-by-adish_21-3ka5
\n\n# Complexity\n\n- Time complexity:\nO(26 * 26)\n\n- Space complexity:\nO(26)\n\n\n# Code\n## Please Upvote if it helps\uD83E\uDD17\n\nclass Solution {\npubl
aDish_21
NORMAL
2024-03-17T07:36:23.041447+00:00
2024-03-17T08:44:49.870294+00:00
111
false
\n\n# Complexity\n```\n- Time complexity:\nO(26 * 26)\n\n- Space complexity:\nO(26)\n```\n\n# Code\n## Please Upvote if it helps\uD83E\uDD17\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int n = word.size(), mini = INT_MAX;\n unordered_map<char, int> mp;\n for(au...
1
0
['Greedy', 'Ordered Map', 'Sorting', 'C++']
0
minimum-deletions-to-make-string-k-special
Minimum Deletions to Make String K-Special
minimum-deletions-to-make-string-k-speci-mus9
Intuition\nvery simple\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O
darthVader26
NORMAL
2024-03-17T05:43:33.619235+00:00
2024-03-17T05:43:33.619282+00:00
159
false
# Intuition\nvery simple\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int solve(i...
1
0
['Dynamic Programming', 'Memoization', 'Java']
1
minimum-deletions-to-make-string-k-special
DP Memoization
dp-memoization-by-kushal1605-4fvo
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Kushal1605
NORMAL
2024-03-17T05:18:28.200224+00:00
2024-03-17T05:18:28.200249+00:00
59
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Java']
0
minimum-deletions-to-make-string-k-special
Minimum Deletions to make String K-Special: Efficient HashMap Algo
minimum-deletions-to-make-string-k-speci-ywsa
Intuition\nThe intuition behind this code is to find the minimum number of deletions required to make the frequency of each character in the string word at most
madhusudanrathi99
NORMAL
2024-03-17T05:05:28.938889+00:00
2024-03-17T05:05:28.938907+00:00
58
false
# Intuition\nThe intuition behind this code is to find the minimum number of deletions required to make the frequency of each character in the string `word` at most `k`.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. **Initialize Variables**: \nThe code initializes a dictionary `...
1
0
['Hash Table', 'String', 'Sorting', 'C#']
0
minimum-deletions-to-make-string-k-special
Explained-Solution with Intuition || AC ✅
explained-solution-with-intuition-ac-by-g1sh1
Intuition\n * We want to make freq[i] - freq[j] <=k for all i and j. \n * find frequency of all characters and sort them. \n * At max we have 26 characters s
satyam_9911
NORMAL
2024-03-17T04:28:10.007787+00:00
2024-03-17T04:33:29.564010+00:00
98
false
# Intuition\n * We want to make ```freq[i] - freq[j] <=k ``` for all `i` and `j`. \n * find frequency of all characters and sort them. \n * At max we have 26 characters so , size of the `freq` can be of `26`.\n * Now , as we can only decrease the freq of characaters , so first we choose `freq[0]` as `minimum`.\n \...
1
0
['Hash Table', 'Sorting', 'Prefix Sum', 'C++']
0
minimum-deletions-to-make-string-k-special
[With Explanation] Frequency + Sort
with-explanation-frequency-sort-by-manis-wrcj
Code Explanation\n\nFill the Frequency Array: Iterate through each character of the input word and increment the count in corresponding position.\n\nSort the Fr
manisreekar
NORMAL
2024-03-17T04:22:45.705035+00:00
2024-03-17T04:56:44.159117+00:00
102
false
# Code Explanation\n\n**Fill the Frequency Array:** Iterate through each character of the input word and increment the count in corresponding position.\n\n**Sort the Frequency Array:** The count array is sorted so that it simplifies the process of calculating the minimum deletions required.\n\n**Calculate Minimum Delet...
1
0
['Java']
0
minimum-deletions-to-make-string-k-special
Python: frequencies of characters, linear solution
python-frequencies-of-characters-linear-kugvt
Intuition\n\nIt is clear that the string does not matter and you need to calculate the frequencies of each characters and sort them.\n\nLets assume that your ar
salvadordali
NORMAL
2024-03-17T04:14:42.223532+00:00
2024-03-17T04:14:42.223554+00:00
33
false
# Intuition\n\nIt is clear that the string does not matter and you need to calculate the frequencies of each characters and sort them.\n\nLets assume that your array is `1, 3, 5, 5, 7, 8, 9, 11, 14` and `k = 4`.\n\nIf you start at position `2`, then you need to remove all the frequencies below this position (cost will ...
1
0
['Python']
1
minimum-deletions-to-make-string-k-special
Hashmap + Sort + Binary Search + Recursion JS
hashmap-sort-binary-search-recursion-js-6hw8a
\n# Code\n\n/**\n * @param {string} word\n * @param {number} k\n * @return {number}\n */\nvar minimumDeletions = function(word, k) {\n const map = new Map()\
geeni_10
NORMAL
2024-03-17T04:04:27.365576+00:00
2024-03-17T04:04:27.365604+00:00
111
false
\n# Code\n```\n/**\n * @param {string} word\n * @param {number} k\n * @return {number}\n */\nvar minimumDeletions = function(word, k) {\n const map = new Map()\n \n for (const char of word) {\n if (map.has(char)) {\n map.set(char, map.get(char) + 1)\n } else {\n map.set(char...
1
0
['JavaScript']
2
minimum-deletions-to-make-string-k-special
C++ || EASY || Hashing || beginner friendly
c-easy-hashing-beginner-friendly-by-been-gd53
\n\n# Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n // Count the frequencies of characters in the word\n vec
SprihaAnand
NORMAL
2024-03-17T04:01:39.423026+00:00
2024-03-17T04:01:39.423059+00:00
73
false
\n\n# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n // Count the frequencies of characters in the word\n vector<int> freq(26, 0);\n for (char c : word) {\n freq[c - \'a\']++;\n }\n \n // Extract the frequencies and sort them i...
1
0
['Hash Table', 'Hash Function', 'C++']
0
minimum-deletions-to-make-string-k-special
Python3 solution || Beginner friendly
python3-solution-beginner-friendly-by-sy-o33k
\nclass Solution(object):\n def minimumDeletions(self, word, k):\n a=list(Counter(word).values())\n a.sort(reverse=True)\n ans=float("in
Syamkrishnareddypulagam
NORMAL
2024-03-17T04:00:56.999743+00:00
2024-03-17T04:04:25.309300+00:00
221
false
```\nclass Solution(object):\n def minimumDeletions(self, word, k):\n a=list(Counter(word).values())\n a.sort(reverse=True)\n ans=float("inf")\n for i in range(len(a)):\n temp=0\n for j in a:\n """\n j can be in 3 cases. \n ...
1
1
['Array', 'Hash Table', 'Math', 'Sorting', 'Python3']
1
minimum-deletions-to-make-string-k-special
Interesting efficient O(n) O(1) solution
interesting-efficient-on-o1-solution-by-mttbw
IntuitionApproachComplexity Time complexity: O(n) Space complexity: O(1) Code
shmirrakhimov
NORMAL
2025-03-27T18:34:48.567035+00:00
2025-03-27T18:34:48.567035+00:00
2
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(n) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ -->...
0
0
['Hash Table', 'Sorting', 'Counting', 'JavaScript']
0
minimum-deletions-to-make-string-k-special
🚀 Mastering Character Deletions: The Ultimate Strategy to Minimize Changes! 🔥Easy Explanation!
mastering-character-deletions-the-ultima-lco1
IntuitionThe goal of this problem is to minimize the number of character deletions required to make the frequency difference between the most and least occurrin
Saurabhabd_360-45
NORMAL
2025-02-13T14:01:53.961030+00:00
2025-02-13T14:01:53.961030+00:00
4
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The goal of this problem is to minimize the number of character deletions required to make the frequency difference between the most and least occurring characters at most k. This is done by removing characters with either the lowest or hig...
0
0
['String', 'Dynamic Programming', 'Sorting', 'Counting', 'Java']
0
minimum-deletions-to-make-string-k-special
O(n) with sorting beating 100%
on-with-sorting-beating-100-by-lilongxue-vz92
IntuitionCount the freq of each letter, and handle the freqs.Approach Count the freq of each letter. Sort the freqs. For each index in freqs, we must try to dro
lilongxue
NORMAL
2025-02-02T18:20:52.146052+00:00
2025-02-02T18:20:52.146052+00:00
4
false
# Intuition Count the freq of each letter, and handle the freqs. # Approach 1. Count the freq of each letter. 2. Sort the freqs. 3. For each index in freqs, we must try to drop off the freqs to its left, and meanwhile, we must do some cutting from the right of the remaining array. 4. For each index, the above two opera...
0
0
['JavaScript']
0
minimum-deletions-to-make-string-k-special
Memoization DP JAVA
memoization-dp-java-by-prachikumari-wdlf
IntuitionTarget : To get minDeletion to get the character freq in range k In order to minimise : we can either delete the character with least freq , hence del
PrachiKumari
NORMAL
2025-01-09T07:35:25.376605+00:00
2025-01-09T07:35:25.376605+00:00
2
false
# Intuition Target : To get minDeletion to get the character freq in range k In order to minimise : - we can either `delete the character with least freq` , hence del of character with least freq -` Delete the character with highest freq ` # Approach - Get all character freq in Array - Then Sort the freqArray in as...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
Check all ranges
check-all-ranges-by-theabbie-zkxm
\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n n = len(word)\n ctr = Counter(word)\n res = float(\'inf\')\n
theabbie
NORMAL
2024-12-24T06:17:07.944740+00:00
2024-12-24T06:17:07.944774+00:00
1
false
```\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n n = len(word)\n ctr = Counter(word)\n res = float(\'inf\')\n for minf in range(1, n + 1):\n maxf = minf + k\n curr = 0\n for c in ctr:\n if ctr[c] < minf:\n ...
0
0
['Python']
0
minimum-deletions-to-make-string-k-special
Constant time-space complexity Solution ( sigma = size Lang = 26 [a-z] lowercase ) leveraging maps
constant-time-space-complexity-solution-6b7he
Intuition and ApproachSee problem descriptionComplexity Time complexity: O(1) Space complexity: O(1) ( Explicit ) O(1) ( Implicit ) Code
2018hsridhar
NORMAL
2024-12-21T20:49:25.473765+00:00
2024-12-21T20:49:25.473765+00:00
5
false
# Intuition and Approach See problem description # Complexity - Time complexity: $$O(1)$$ - Space complexity: $$O(1)$$ ( Explicit ) $$O(1)$$ ( Implicit ) # Code ```python3 [] ''' URL := https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/description/ 3085. Minimum Deletions to Make String K-Spec...
0
0
['Python3']
0
minimum-deletions-to-make-string-k-special
Simple Java Solution
simple-java-solution-by-sakshikishore-nu6o
Code
sakshikishore
NORMAL
2024-12-14T19:12:01.222292+00:00
2024-12-14T19:12:01.222292+00:00
3
false
# Code\n```java []\nclass Solution {\n int result=Integer.MAX_VALUE;\n public void Solve(int arr[],int i, int j, int score,int k)\n {\n \n if(i>=j)\n {\n result=Math.min(result,score);\n return;\n }\n if(arr[j]-arr[i]<=k)\n {\n \n ...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
Using hashmap Step wise commented code
using-hashmap-brute-force-by-sapilol-w3gx
null
LeadingTheAbyss
NORMAL
2024-12-11T09:15:38.096598+00:00
2024-12-11T09:17:00.002265+00:00
4
false
# Code\n```cpp []\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n // Step 1: Count the frequency of each character in the word\n unordered_map<char, int> mpp;\n for (char c : word) mpp[c]++; // Iterate through the word and increment the count of each character\n\n ...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
C++
c-by-tinachien-l2xk
\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n unordered_map<char, int>Map;\n for(auto ch : word){\n Map
TinaChien
NORMAL
2024-12-04T10:32:14.450551+00:00
2024-12-04T10:32:14.450584+00:00
1
false
```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n unordered_map<char, int>Map;\n for(auto ch : word){\n Map[ch]++;\n }\n vector<int>Count;\n for(auto [_, t] : Map){\n Count.push_back(t);\n }\n sort(Count.begin(), Count...
0
0
[]
0
minimum-deletions-to-make-string-k-special
Python 1-liner
python-1-liner-by-dsapelnikov-h6kt
Code\npython3 []\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n return (freq := Counter(list(word)).values()) and min(sum(
dsapelnikov
NORMAL
2024-11-21T22:46:09.625143+00:00
2024-11-21T22:46:09.625173+00:00
2
false
# Code\n```python3 []\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n return (freq := Counter(list(word)).values()) and min(sum(f if f < ref else max(f - ref - k, 0) for f in freq) for ref in freq)\n```
0
0
['Python3']
0
minimum-deletions-to-make-string-k-special
brute force
brute-force-by-czxoxo-trd7
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
czxoxo
NORMAL
2024-11-18T22:07:24.425516+00:00
2024-11-18T22:07:24.425549+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
Freq count - Java O(26*26)|O(26)
freq-count-java-o2626o26-by-wangcai20-5k7k
Intuition\n Describe your first thoughts on how to solve this problem. \n Build freq array. \n Loop over each freq, calulate count by adding all lower freq and
wangcai20
NORMAL
2024-10-25T16:19:56.058780+00:00
2024-10-25T16:21:26.832855+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* Build freq array. \n* Loop over each freq, calulate `count` by adding all lower freq and higher freq beyond current freq + k.\n* Find the minimum `count`.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Compl...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
[Java] ✅ 100% ✅ SLIDING WINDOW ✅ FASTEST ✅ BEST ✅ CLEAN CODE
java-100-sliding-window-fastest-best-cle-r4ia
Approach\n1. Get the frequency of the characters: charFreq[].\n2. Sort and trim (do not include 0 freq) in the charFreq. Now charFreq is like [1,1,3,4,7,8,9]\n3
StefanelStan
NORMAL
2024-10-25T01:43:17.857953+00:00
2024-10-25T01:43:17.857978+00:00
2
false
# Approach\n1. Get the frequency of the characters: charFreq[].\n2. Sort and trim (do not include 0 freq) in the charFreq. Now charFreq is like [1,1,3,4,7,8,9]\n3. Looking at K (max diff), we see this is actually a window. (left, right): [1,1,3,4,7,8,9]\n - at freq of 1 (left) , you can have a max freq of 1 + k (rig...
0
0
['Two Pointers', 'Sliding Window', 'Java']
0
minimum-deletions-to-make-string-k-special
Beats 100% -----> Simple Approach
beats-100-simple-approach-by-vatan999-hh8v
Intuition\nThe problem involves reducing character frequencies to a manageable level by performing deletions. The goal is to minimize the number of deletions re
vatan999
NORMAL
2024-10-22T14:27:49.364482+00:00
2024-10-22T14:27:49.364518+00:00
0
false
# Intuition\nThe problem involves reducing character frequencies to a manageable level by performing deletions. The goal is to minimize the number of deletions required to ensure that the difference between the frequencies of any two characters does not exceed a given threshold `k`.\n\n# Approach\n1. **Count Frequencie...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
sexy + hot code
sexy-hot-code-by-rajan_singh5639-7gdk
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
rajan_singh5639
NORMAL
2024-09-17T13:50:15.617869+00:00
2024-09-17T13:50:15.617903+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
HOT + SEXY CODE
hot-sexy-code-by-rajan_singh5639-eydk
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
rajan_singh5639
NORMAL
2024-09-17T11:50:06.074739+00:00
2024-09-17T11:50:06.074781+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
5 ms Beats 97.91%
5-ms-beats-9791-by-pribyte1-2vqg
Code\njava []\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int freq[]=new int[26];\n for(int i=0;i<word.length();i++
pribyte1
NORMAL
2024-09-03T04:32:26.152557+00:00
2024-09-03T04:32:26.152598+00:00
1
false
# Code\n```java []\nclass Solution {\n public int minimumDeletions(String word, int k) {\n int freq[]=new int[26];\n for(int i=0;i<word.length();i++){\n freq[word.charAt(i)-\'a\']++;\n }\n Arrays.sort(freq);\n int res=Integer.MAX_VALUE;\n for(int i=0;i<26;i++){\n ...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
Beats 100% time | 86% space || easy solution using frequency array
beats-100-time-86-space-easy-solution-us-x1h6
Complexity\n- Time complexity: 0(n)\n- Beats complexity: 0(everybody)\n- Space complexity: 0(n)\n\n# Code\ncpp []\nclass Solution {\npublic:\n int minimumDel
Nazar_Zakrevski
NORMAL
2024-08-29T09:04:33.546853+00:00
2024-08-29T09:04:33.546879+00:00
4
false
# Complexity\n- Time complexity: 0(n)\n- Beats complexity: 0(everybody)\n- Space complexity: 0(n)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n vector<int> arr(26);\n ...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
C++ || simple solution
c-simple-solution-by-rohityadav2002-6tty
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
RohitYadav2002
NORMAL
2024-08-20T15:09:52.597273+00:00
2024-08-20T15:09:52.597308+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
Easy Solution C++ Greedy✅✅✅
easy-solution-c-greedy-by-jayesh_06-aoy4
\n\n# Code\n\nclass Solution {\npublic:\n\n int minimumDeletions(string word, int k) {\n int n = word.size();\n map<char, int> mp;\n for
Jayesh_06
NORMAL
2024-08-05T11:48:54.491459+00:00
2024-08-05T11:48:54.491496+00:00
0
false
\n\n# Code\n```\nclass Solution {\npublic:\n\n int minimumDeletions(string word, int k) {\n int n = word.size();\n map<char, int> mp;\n for (int i = 0; i < n; i++) {\n mp[word[i]]++;\n }\n int i = 1, mini = n;\n int j = min(i + k, n);\n while (j <= n) {\n ...
0
0
['Hash Table', 'String', 'Greedy', 'Sorting', 'Counting', 'C++']
0
minimum-deletions-to-make-string-k-special
O(n) Soln
on-soln-by-ozzyozbourne-gq7r
Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n# Code
ozzyozbourne
NORMAL
2024-08-01T00:08:48.506164+00:00
2024-08-01T00:10:15.295598+00:00
11
false
# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n``` python []\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n map, ans = [0] * 26, float(...
0
0
['Java', 'Python3', 'Rust']
0
minimum-deletions-to-make-string-k-special
Sort char frequency and check window with k
sort-char-frequency-and-check-window-wit-6ian
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
linda2024
NORMAL
2024-07-16T17:26:33.465064+00:00
2024-07-16T17:26:33.465112+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C#']
0
minimum-deletions-to-make-string-k-special
Python || Simple and Easy Solution
python-simple-and-easy-solution-by-vilap-q3ix
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
vilaparthibhaskar
NORMAL
2024-07-02T09:44:09.332254+00:00
2024-07-02T09:44:09.332296+00:00
8
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Hash Table', 'Greedy', 'Sorting', 'Python3']
0
minimum-deletions-to-make-string-k-special
More Intuitive Dp approach
more-intuitive-dp-approach-by-divyam_1-cqhu
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Divyam_1
NORMAL
2024-06-23T02:41:34.694949+00:00
2024-06-23T02:41:34.694979+00:00
4
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
Solution explained with diagrams.
solution-explained-with-diagrams-by-nan-y6h97
Approach\n\n\n# Code\n\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n counts = Counter(word)\n values = list(sorted
nan-do
NORMAL
2024-06-21T04:04:12.567502+00:00
2024-06-21T04:04:12.567530+00:00
8
false
# Approach\n![3085.png](https://assets.leetcode.com/users/images/ef773042-2589-4b67-b4e0-1b2d9a359354_1718942518.1501184.png)\n\n# Code\n```\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n counts = Counter(word)\n values = list(sorted(counts.values(), reverse=True))\n\n ...
0
0
['Python3']
0
minimum-deletions-to-make-string-k-special
3 solutions | Greedy, DFS/Rec, Memoization (DP)
3-solutions-greedy-dfsrec-memoization-dp-nmhq
Solution-1: Greedy (WA -- 688 / 732 TCs passed -- 93.98%)\n+ IDEA: At each stage, we\'re greedily picking the smallest required change. i.e either mn (min eleme
shahsb
NORMAL
2024-06-17T05:37:16.729432+00:00
2024-07-02T03:35:51.635719+00:00
7
false
# Solution-1: Greedy (WA -- 688 / 732 TCs passed -- 93.98%)\n+ **IDEA:** At each stage, we\'re greedily picking the smallest required change. i.e either `mn` (min element) or `mx-mn-k` (removing diff from max element).\n+ **NOTE:** Kindly note that this solution only passes 93.98% of TCs. Intention behind sharing this ...
0
0
['Dynamic Programming', 'Greedy', 'Depth-First Search', 'Recursion', 'Memoization', 'C']
0
minimum-deletions-to-make-string-k-special
TOO EASY DP
too-easy-dp-by-mohdibrahim12123-e5ki
Intuition\ndp\n\n# Approach\ndp\n\n# Complexity\n- Time complexity:\no(2626)\n\n- Space complexity:\no(2626)\n\n# Code\n\nclass Solution {\npublic:\n int hel
mohdibrahim12123
NORMAL
2024-06-16T17:41:26.270998+00:00
2024-06-16T17:41:26.271065+00:00
3
false
# Intuition\ndp\n\n# Approach\ndp\n\n# Complexity\n- Time complexity:\no(26*26)\n\n- Space complexity:\no(26*26)\n\n# Code\n```\nclass Solution {\npublic:\n int helper(int i,int j,vector<int> &freq,int k,vector<vector<int>> &dp)\n {\n if(i==j || freq[j]-freq[i]<=k)\n return 0;\n if(dp[i][j]!=...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
[Rust] Beats 100% -- it's not O(n^2) if you only have 26 letters
rust-beats-100-its-not-on2-if-you-only-h-tz7w
Intuition\nFirst thing, we need to count the number of frequency of each letter in word, and sort them so we can easily identify low frequencies and high freque
tiedyedvortex
NORMAL
2024-06-15T14:10:31.713108+00:00
2024-06-15T14:10:31.713143+00:00
1
false
# Intuition\nFirst thing, we need to count the number of frequency of each letter in word, and sort them so we can easily identify low frequencies and high frequencies.\n\nThen, when faced with a frequency distribution, we have two approaches to reduce it down to some range.\n\nOne option would be to keep the lowest-fr...
0
0
['Rust']
0
minimum-deletions-to-make-string-k-special
3085. Minimum Deletions to Make String K-Special
3085-minimum-deletions-to-make-string-k-4l5od
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Priyankaaaaa
NORMAL
2024-06-10T14:47:17.942656+00:00
2024-06-10T14:47:17.942686+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
SImple solution
simple-solution-by-risabhuchiha-16h0
\n\nclass Solution {\n Integer[][]dp=new Integer[26][26];\n public int minimumDeletions(String word, int k) {\n int[]a=new int[26];\n for(ch
risabhuchiha
NORMAL
2024-06-09T01:54:39.259569+00:00
2024-06-09T01:54:39.259601+00:00
4
false
\n```\nclass Solution {\n Integer[][]dp=new Integer[26][26];\n public int minimumDeletions(String word, int k) {\n int[]a=new int[26];\n for(char ch:word.toCharArray()){\n a[ch-\'a\']++;\n}\n//if(word.length()==1)return 0;\nint ans=0;\nArrays.sort(a);\nint j=0;\nwhile(a[j]==0)j++;\n //ret...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
simple java solution
simple-java-solution-by-lavlesh_pandey-jtbh
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
lavlesh_pandey
NORMAL
2024-06-08T08:16:52.981763+00:00
2024-06-08T08:16:52.981784+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Array', 'String', 'Java']
0
minimum-deletions-to-make-string-k-special
✅counting->DP || cPP
counting-dp-cpp-by-darkenigma-8con
\n# Code\n\nclass Solution {\npublic:\n\n int solve(vector<int>& arr,vector<vector<int>>& dp,int i,int j,int k){\n if(i==j || arr[j]-arr[i]<=k)return
darkenigma
NORMAL
2024-06-04T18:13:16.628082+00:00
2024-06-04T18:13:16.628119+00:00
0
false
\n# Code\n```\nclass Solution {\npublic:\n\n int solve(vector<int>& arr,vector<vector<int>>& dp,int i,int j,int k){\n if(i==j || arr[j]-arr[i]<=k)return 0;\n if(dp[i][j]!=-1)return dp[i][j];\n return dp[i][j]=min(arr[i]+solve(arr,dp,i+1,j,k),arr[j]-arr[i]-k+solve(arr,dp,i,j-1,k));\n }\n in...
0
0
['Hash Table', 'String', 'Sorting', 'Counting', 'C++']
0
minimum-deletions-to-make-string-k-special
O(n)...bahu saras solutioon
onbahu-saras-solutioon-by-gungun16-rtlu
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Gungun16
NORMAL
2024-05-16T04:41:08.991524+00:00
2024-05-16T04:41:08.991564+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
gujju_ben_ni_gamzzat # Bahu saras O(n) ma solution...
gujju_ben_ni_gamzzat-bahu-saras-on-ma-so-vc3a
Intuition\n Describe your first thoughts on how to solve this problem. \nDarek character ni frequency par jau 6u and then check karu 6u ke ae character ni frequ
Gungun16
NORMAL
2024-05-16T03:52:30.242011+00:00
2024-05-16T03:52:30.242042+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDarek character ni frequency par jau 6u and then check karu 6u ke ae character ni frequency jetli bija badha j characters ni frequency ne karvi hoi to su karvanu.\n\nSau pratham to tamare badha j characters ni frequecny ne calculate kari ...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
Minimum prefix removal
minimum-prefix-removal-by-vokasik-u8ip
The long description asks us to find minimum number of chars to be removed so that the diff between any 2 frequencies in word <= k.\n2. Find frequencies with Co
vokasik
NORMAL
2024-05-10T23:04:02.058579+00:00
2024-05-10T23:04:02.058598+00:00
5
false
1. The long description asks us to find **minimum** number of chars to be removed so that the diff between any 2 frequencies in `word` <= k.\n2. Find frequencies with Counter/whatever\n3. Now we need to remove minimum chars and satisfy the condition: `|any_freq - any_other_freq| <= k`\n\nLet\'s look at a few examples t...
0
0
['Prefix Sum', 'Python', 'Python3']
0
minimum-deletions-to-make-string-k-special
Shortest, Easiest, Clean & Clear | To the Point & Beginners Friendly Approach (❤️ ω ❤️)
shortest-easiest-clean-clear-to-the-poin-657a
Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n vector<int>v(26,0);\n for(auto i:word)v[i-\'a\']++;\n i
Nitansh_Koshta
NORMAL
2024-04-28T08:12:53.268313+00:00
2024-04-28T08:12:53.268339+00:00
2
false
# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n vector<int>v(26,0);\n for(auto i:word)v[i-\'a\']++;\n int y=INT_MAX;\n for(int i=0;i<v.size();i++){\n int x=0;\n for(int j=0;j<v.size();j++){\n if(i!=j&&v[j]<v[i])x+=...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
images | notes | c++ | greedy
images-notes-c-greedy-by-rahullodhi12-ehl5
Notes\n\n\n\n# Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int ans = word.length();\n vector<int> freq(26,
rahullodhi12
NORMAL
2024-04-22T12:39:43.270443+00:00
2024-04-22T12:39:43.270475+00:00
8
false
# Notes\n![IMG_20240422_180454.jpg](https://assets.leetcode.com/users/images/f96b08c8-5734-4444-ab97-93d37e1368ce_1713789547.8194153.jpeg)\n![IMG_20240422_180502.jpg](https://assets.leetcode.com/users/images/a6ca4ff2-ce7a-4e95-b818-adb2c0d4abf0_1713789534.9360988.jpeg)\n\n# Code\n```\nclass Solution {\npublic:\n int...
0
0
['Hash Table', 'String', 'Greedy', 'Sorting', 'Counting', 'C++']
0
minimum-deletions-to-make-string-k-special
O(N) Easiest java solution.
on-easiest-java-solution-by-marshadow54-z2o5
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
marshadow54
NORMAL
2024-04-20T12:37:43.654390+00:00
2024-04-20T12:37:43.654435+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
minimum-deletions-to-make-string-k-special
Move window start over frequencies, 94% speed
move-window-start-over-frequencies-94-sp-x7uh
image.png\n\n\n# Code\n\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n freq = list(Counter(word).values())\n ans =
evgenysh
NORMAL
2024-04-17T15:20:10.753257+00:00
2024-04-17T15:20:10.753294+00:00
9
false
image.png\n![image.png](https://assets.leetcode.com/users/images/4efa8c96-1117-4b39-a92f-bb05e22cc0ac_1713367198.2275133.png)\n\n# Code\n```\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n freq = list(Counter(word).values())\n ans = len(word)\n for start in set(freq):\...
0
0
['Python3']
0
minimum-deletions-to-make-string-k-special
Proof of correctness
proof-of-correctness-by-ram_raghav-byn8
As suggested by the hint, the following result can be used to solve the problem.\n\n*\nLet $new\_word$ be a k-simple word formed after perfoming the minimum num
Ram_Raghav
NORMAL
2024-04-13T23:55:59.339579+00:00
2024-04-14T00:03:28.318445+00:00
11
false
As suggested by the hint, the following result can be used to solve the problem.\n\n****\nLet $new\\_word$ be a k-simple word formed after perfoming the minimum number of deletions from word. Then there exists a character $c$ in $new\\_word$ that is never deleted. i.e., its frequency in $new\\_word$ is equal to its fre...
0
0
['Python3']
0
minimum-deletions-to-make-string-k-special
sliding window python
sliding-window-python-by-russellleung-6w00
class Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n \n counter=Counter(word)\n values=sorted(counter.values())\n
russellleung
NORMAL
2024-04-10T03:44:45.261896+00:00
2024-04-10T03:44:45.261921+00:00
0
false
class Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n \n counter=Counter(word)\n values=sorted(counter.values())\n i=0\n total=0\n ans=float("inf")\n for j in range(len(values)):\n while i<len(values) and values[i]-values[j]<=k:\n ...
0
0
[]
0
minimum-deletions-to-make-string-k-special
👌Runtime 14 ms Beats 77.08% of users with Go
runtime-14-ms-beats-7708-of-users-with-g-kgdr
Code\n\nfunc minimumDeletions(word string, k int) int {\n\tfreq := make([]int, 26)\n\tfor _, ch := range word {\n\t\tfreq[ch-\'a\']++\n\t}\n\n\tsort.Ints(freq)\
pvt2024
NORMAL
2024-04-09T01:20:26.343986+00:00
2024-04-09T01:20:26.344015+00:00
5
false
# Code\n```\nfunc minimumDeletions(word string, k int) int {\n\tfreq := make([]int, 26)\n\tfor _, ch := range word {\n\t\tfreq[ch-\'a\']++\n\t}\n\n\tsort.Ints(freq)\n\tminDel := int(^uint(0) >> 1) // MaxInt\n\n\tfor i := len(freq) - 1; i >= 0; i-- {\n\t\ttrgt := freq[i]\n\t\tdels := 0\n\n\t\tfor _, f := range freq {\n\...
0
0
['Go']
0
minimum-deletions-to-make-string-k-special
C++ | Greedy
c-greedy-by-pikachuu-79nr
Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int freq[26] = {0};\n for(int i = 0; i < word.size(); i++) {\n
pikachuu
NORMAL
2024-04-05T16:43:15.847611+00:00
2024-04-05T16:43:15.847643+00:00
7
false
# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int freq[26] = {0};\n for(int i = 0; i < word.size(); i++) {\n freq[word[i] - \'a\']++;\n }\n int ans = INT_MAX;\n for(int i = 0; i < 26; i++) {\n int del = 0;\n f...
0
0
['String', 'Greedy', 'Counting', 'C++']
0
minimum-deletions-to-make-string-k-special
[C++][Prefix sum]
cprefix-sum-by-mumrocks-t70n
\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n /*\n a->1 b->2 c->3 d->5\n */\n vector<int> cnt(26);\n
MumRocks
NORMAL
2024-04-03T14:09:15.762038+00:00
2024-04-03T14:09:15.762066+00:00
2
false
```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n /*\n a->1 b->2 c->3 d->5\n */\n vector<int> cnt(26);\n for(const auto w: word) cnt[w-\'a\']++;\n \n vector<int> dp;\n for (int i=0;i<26;i++) if (cnt[i]>0) dp.push_back(cnt[i]);\n ...
0
0
[]
0
minimum-deletions-to-make-string-k-special
Easy C++ Prefix sum + Greedy
easy-c-prefix-sum-greedy-by-parteek_code-w707
\n\n# Code\n\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int n = word.size();\n if(n<=1) return 0;\n vecto
parteek_coder
NORMAL
2024-04-03T04:39:01.506368+00:00
2024-04-03T04:39:01.506397+00:00
6
false
\n\n# Code\n```\nclass Solution {\npublic:\n int minimumDeletions(string word, int k) {\n int n = word.size();\n if(n<=1) return 0;\n vector<int>alpha(26,0);\n vector<int>prefix(26,0);\n for(auto ch: word){\n alpha[ch-\'a\']++;\n }\n\n sort(alpha.begin(),al...
0
0
['C++']
0
minimum-deletions-to-make-string-k-special
Python Medium
python-medium-by-lucasschnee-w2ac
\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n c = Counter(word)\n arr = list(c.values())\n arr.sort()\n
lucasschnee
NORMAL
2024-04-03T02:03:36.413365+00:00
2024-04-03T02:03:36.413416+00:00
9
false
```\nclass Solution:\n def minimumDeletions(self, word: str, k: int) -> int:\n c = Counter(word)\n arr = list(c.values())\n arr.sort()\n N = len(arr)\n \'\'\'\n [1, 2]\n \n can also make chars 0\n \'\'\'\n # median = arr[N//2]\n # if N % 2 ...
0
0
['Python3']
0
minimum-deletions-to-make-string-k-special
scala solution
scala-solution-by-vititov-62bg
\nobject Solution {\n def minimumDeletions(word: String, k: Int): Int = {\n lazy val freqs = word.groupMapReduce(identity)(_ => 1)(_ + _).values.to(List)\n
vititov
NORMAL
2024-03-30T20:59:23.984248+00:00
2024-03-30T20:59:23.984282+00:00
2
false
```\nobject Solution {\n def minimumDeletions(word: String, k: Int): Int = {\n lazy val freqs = word.groupMapReduce(identity)(_ => 1)(_ + _).values.to(List)\n freqs.distinct.map{f => freqs.collect{\n case g if g<f => g\n case g if g-f > k => g-f-k \n }.sum\n }.min\n }\n}\n```
0
0
['Scala']
0