haoel / leetcode

LeetCode Problems' Solutions
17.57k stars 4.91k forks source link

Is this a bug with “Longest Substring Without Repeating Characters”? #149

Open wangkuiyi opened 6 years ago

wangkuiyi commented 6 years ago

https://github.com/haoel/leetcode/blob/725a380d5c2644dfadb5498dd3ec8596b5e59618/algorithms/cpp/longestSubstringWithoutRepeatingCharacters/longestSubstringWithoutRepeatingCharacters.cpp#L47

I’d thought that memset initialize bytes but not integers?

Dev-XYS commented 6 years ago

Setting all the bytes of a integer to -1 (0xFF) results in the integer becoming 0xFFFFFFFF (-1).