力扣第三题求错误的地方

class Solution {
public:
	int lengthOfLongestSubstring(string s) {
		unordered_map<char,int> hashmap;
		int max=0;
		unordered_map<char, int>::iterator it;
		for (int i = 0; i < s.size(); i++)
		{
			it = hashmap.find(s[i]);
			if (it == hashmap.end())
			{
				hashmap[s[i]] = i;
			}
			else {
				max = max < hashmap.size() ? hashmap.size() : max;
				it++;
				hashmap.erase(hashmap.begin(), it);
				hashmap[s[i]] = i;
			}
			max = max < hashmap.size() ? hashmap.size():max;
		}
		return max;
	}
};

同一个示例,vs跑出来的结果是对的,但上传力扣是错的。

题目贴一下。。不然都不知道你解决的什么问题。

你好,我是有问必答小助手。为了技术专家团更好地为您解答问题,烦请您补充下(1)问题背景详情,(2)您想解决的具体问题,(3)问题相关代码图片或者报错信息。便于技术专家团更好地理解问题,并给出解决方案。

您可以点击问题下方的【编辑】,进行补充修改问题。