409. Longest Palindrome | Hash Table | Greedy | Hot Interview Question

  Рет қаралды 3,511

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 13
@mugdhashrivastava
@mugdhashrivastava 7 ай бұрын
hehe that ki haal chaal in intro every time is kinda cute
@Saurabh_Shukla31
@Saurabh_Shukla31 7 ай бұрын
class Solution { public: int longestPalindrome(string s) { int n = s.length(); int ans = 0; bool isodd = false; vector mpp(256, 0); for (int i = 0; i < n; i++) { mpp[s[i]]++; } for (int i = 0; i < mpp.size(); i++) { if (mpp[i] % 2 == 0) { ans += mpp[i]; } else { ans += mpp[i] - 1; isodd = true; } } if (isodd) { ans += 1; } return ans; } };
@Manishgupta200
@Manishgupta200 7 ай бұрын
Almost done by me. Good explaination
@cdjamse3944
@cdjamse3944 7 ай бұрын
worked for 46 test cases for me
@ishan_19
@ishan_19 7 ай бұрын
I don't know why I chose a lengthy approach of generating subsequences and checking the longest palindrome :) This is way better and much simpler to implement
@anonymousanonymous7507
@anonymousanonymous7507 7 ай бұрын
ur original code?
@spaceadvanture6458
@spaceadvanture6458 7 ай бұрын
"aacc" ka kya, ye tho palindrome bhi nh hai,aur question mai diya nhi hai ki substrig palindrome hoga hi..
@aizad786iqbal
@aizad786iqbal 7 ай бұрын
i did a similar approach and i got the result as 17 ms, is this just a leet code thing? one suggestion, start doing live coding instead, it'll be more helpful imo
@tushar404
@tushar404 7 ай бұрын
yes it is although mera 100 % aagaya tha pehla attempt me hi
@sanjivaniburma6171
@sanjivaniburma6171 7 ай бұрын
bhai ki x hai
@UECAshutoshKumar
@UECAshutoshKumar 7 ай бұрын
Thank you
@mayankshakya9200
@mayankshakya9200 7 ай бұрын
// isme kyu accept nhi ho rha?? class Solution { public: int longestPalindrome(string s) { int n=s.size(); unordered_mapmp; for(int i=0;i
@tushar404
@tushar404 7 ай бұрын
bhai x ki mkc🤬😡 (3:00)
1002. Find Common Characters | Implementation | Array
13:17
Aryan Mittal
Рет қаралды 3,6 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
Longest Palindrome - Leetcode 409 - Python
12:20
NeetCodeIO
Рет қаралды 16 М.
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 375 М.
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 238 М.
232. Implement Queue using Stacks | Stack & Queue
13:27
Aryan Mittal
Рет қаралды 1,1 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 242 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН