leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

[Bugfix][C++][0242-valid-anagram] Fix wrong iteration of the smap

Open eriktuantran opened this issue 2 years ago • 0 comments

  • File(s) Modified: 0242-valid-anagram.cpp
  • Language(s) Used: C++
  • Submission URL: https://leetcode.com/problems/valid-anagram/submissions/955359421/

Change summary:

Using smap[i] where 0 < i < smap.size() will insert the key i into the map if such key does not already exist (link) This is absolutely not what we want. The fix is to iterate the smap, get the key and compare the value to tmap.

eriktuantran avatar May 22 '23 20:05 eriktuantran