hehe that ki haal chaal in intro every time is kinda cute
@Saurabh_Shukla317 ай бұрын
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; } };
@Manishgupta2007 ай бұрын
Almost done by me. Good explaination
@cdjamse39447 ай бұрын
worked for 46 test cases for me
@ishan_197 ай бұрын
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
@anonymousanonymous75077 ай бұрын
ur original code?
@spaceadvanture64587 ай бұрын
"aacc" ka kya, ye tho palindrome bhi nh hai,aur question mai diya nhi hai ki substrig palindrome hoga hi..
@aizad786iqbal7 ай бұрын
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
@tushar4047 ай бұрын
yes it is although mera 100 % aagaya tha pehla attempt me hi
@sanjivaniburma61717 ай бұрын
bhai ki x hai
@UECAshutoshKumar7 ай бұрын
Thank you
@mayankshakya92007 ай бұрын
// isme kyu accept nhi ho rha?? class Solution { public: int longestPalindrome(string s) { int n=s.size(); unordered_mapmp; for(int i=0;i