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

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

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 13
@mugdhashrivastava
@mugdhashrivastava 8 ай бұрын
hehe that ki haal chaal in intro every time is kinda cute
@Saurabh_Shukla31
@Saurabh_Shukla31 8 ай бұрын
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; } };
@ishan_19
@ishan_19 8 ай бұрын
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?
@Manishgupta200
@Manishgupta200 8 ай бұрын
Almost done by me. Good explaination
@cdjamse3944
@cdjamse3944 8 ай бұрын
worked for 46 test cases for me
@spaceadvanture6458
@spaceadvanture6458 8 ай бұрын
"aacc" ka kya, ye tho palindrome bhi nh hai,aur question mai diya nhi hai ki substrig palindrome hoga hi..
@sanjivaniburma6171
@sanjivaniburma6171 8 ай бұрын
bhai ki x hai
@aizad786iqbal
@aizad786iqbal 8 ай бұрын
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 8 ай бұрын
yes it is although mera 100 % aagaya tha pehla attempt me hi
@mayankshakya9200
@mayankshakya9200 8 ай бұрын
// 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 8 ай бұрын
bhai x ki mkc🤬😡 (3:00)
@UECAshutoshKumar
@UECAshutoshKumar 8 ай бұрын
Thank you
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 270 М.
Correct by Design with TLA+: Gossip Protocol
19:50
Richard Tang
Рет қаралды 2
Hash Tables and Hash Functions
13:56
Computer Science Lessons
Рет қаралды 1,6 МЛН
DP 29. Minimum Insertions to Make String Palindrome
12:00
take U forward
Рет қаралды 176 М.
The SHOCKING Truth About Who Should NOT Code! 🤫
11:50
Aryan Mittal
Рет қаралды 1,9 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 692 М.
How to Remember Everything You Read
26:12
Justin Sung
Рет қаралды 3,6 МЛН
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 377 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 855 М.