Remove Letter To Equalize Frequency || leetcode Biweekly 88 || Leetcode Easy

preview_player
Показать описание
Here in this video we have discussed the approach to solve
" Remove Letter To Equalize Frequency " in hindi.

Please like, Subscribe and share channel for more amazing content :) Also press 👍 the 🔔 icon to get notified quickly.

My name is Pankaj Kumar, ASDE1 @Publicis Sapient
Thanks Everyone😊
----------------------------------------------------------------------------------------------------------------------------------------
Question and Solution Link 👇
----------------------------------------------------------------------------------------------------------------------------------------
Other Link 👇
🔔 Join telegram channel for doubts and discussions:

----------------------------------------------------------------------------------------------------------------------------------------
#leetcode
#binary_magic
#competitive_programming
----------------------------------------------------------------------------------------------------------------------------------------
Remove Letter To Equalize Frequency
Remove Letter To Equalize Frequency leetcode
Remove Letter To Equalize Frequency leetcode solution
Remove Letter To Equalize Frequency leetcode easy
biweekly contest 88
leetcode biweekly contest 88 solution
Remove Letter To Equalize Frequency biweekly contest 88
leetcode solution video
leetcode easy
Рекомендации по теме
Комментарии
Автор

aree bhaiya, 3 approach lga ke dekhi
1st-> 2 unordered map lga ke coz meko (pr question shi se nhi padhta tha toh ek test case hi glt aa gya )
2nd-> sme 2 unordered map lgye aur count bhi kiya frequency ko pe submission pe wrong ans aya
3rd-> ek map aur fir uski freq ko vector mei dala, aur count se calculations ki fir bhi nhi aya lol
pr dekh rha ki dusro nei bhi kuch aisa hi kiya toh thoda confidence boost
btw yeh mera 1st tha pr contest rating nhi dikha rha yha bhi code forces jaisa system h kya ki 2 contest dene honge??
aur ha best of luck for tommorow

vitaminprotein
Автор

Bhaiya mera bhi bahut wrong submissions hue, ek case handle karta hun toh dusra fail ho jata hai, phir apka video dekha, mera khudse 35 / 37 testcase pass hue

My Approach :
bool equalFrequency(string word) {
map<char, int> mp;
for (auto x : word){
mp[x]++;
}
bool f1 = true;
for (int i=1 ; i<word.size() ; i++){
if (word[i] == word[i-1]) {
f1 = false;
break;
}
}
if (f1) return true;

vector<int> v;
for (auto it : mp){
v.push_back(it.second);
}
int maxi = INT_MIN, maxIdx;
for (int i=0 ; i<v.size() ; i++){
if (v[i] > maxi){
maxi = v[i];
maxIdx = i;
}
}
v[maxIdx] -= 1;
set<int> s;
for (auto x : v){
s.insert(x);
}
if (s.size() == 1) return true;
return false;
}

pritishpattnaik
join shbcf.ru