Valid Anagram | Leetcode 242 | Explanation and solution in C++
Vložit
- čas přidán 15. 03. 2021
- Hey everyone, here I have discussed the Q. 242 of leetcode with code in C++.
Connect with me:
Instagram : / i_m_sarvesh__
LinkedIn : / sarvesh-roshan-1429b3158
Github : github.com/imroshan12
great and very simple to understand, thank you
good one!!👍
nice, thank you !
code explanation was nice and effective.
bool isAnagram(string s, string t) {
sort(s.begin() , s.end()) ;
sort(t.begin(), t.end());
if(s==t){
return true;
}
return false;
}
The one in the video is more efficient, I think, Also you can just return s==t;
@@programmer6548 yes , but the code he provided gives out logn time complexity due to sorting but the code in the video is the optimal code.
good explanation