国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

LeetCode 3. Longest Substring Without Repeating Characters

2019-11-08 02:02:46
字體:
來源:轉載
供稿:網友

Given a string, find the length of the longest substring without repeating characters.

Examples:

Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", with the length of 1.Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a subsequence and not a substring.

程序代碼:

int lengthOfLongestSubstring(char* s) { int len = 0,p=0,q=0,i; for(;q<strlen(s);q++) { for(i=p;i<q;i++) { if(s[q]==s[i]) { if(q-p>len) len = q-p; p=i+1; break; } } } len = len>(q-p)?len:q-p; return len;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 襄樊市| 九江市| 砚山县| 喀喇| 威宁| 定边县| 天峻县| 卢湾区| 任丘市| 元谋县| 城步| 修武县| 大田县| 蒙城县| 香港 | 莲花县| 玛曲县| 建湖县| 江华| 黔江区| 册亨县| 镇原县| 屏东县| 会昌县| 芜湖市| 乐清市| 德令哈市| 始兴县| 鄄城县| 克山县| 若尔盖县| 景东| 湖北省| 忻城县| 白沙| 日照市| 报价| 莱西市| 民乐县| 万源市| 深州市|