立扣
扳手的海角
这个作者很懒,什么都没留下…
展开
-
190_leetcode_计算不同字符的个数
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<math.h> using namespace std; //--计算的是不同字符的个数-- class Solution { public: int lengthOfLongestSubstring(string s) { vector<int> m(128, 0原创 2021-11-20 17:47:54 · 687 阅读 · 0 评论 -
189_leetcode_3. 【无重复字符的最长子串】给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度
解法1: class Solution { public: int lengthOfLongestSubstring(string s) { int n = s.length(); if (n < 2) return n;//只有一个字符 int left = 0; int right = 0; int maxlen = 0; //unordered_set不同于set,其中的数据是无序的 //set是自动排序,且不会插入相同的字符 uno原创 2021-11-20 13:58:34 · 686 阅读 · 0 评论