国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 博兴县| 修武县| 应用必备| 江阴市| 汝阳县| 庄河市| 镇康县| 石楼县| 延津县| 平阴县| 马边| 西贡区| 五家渠市| 罗平县| 德庆县| 南京市| 甘肃省| 禹城市| 靖江市| 安阳市| 泰宁县| 通河县| 湟中县| 辽宁省| 青田县| 台山市| 美姑县| 同心县| 高陵县| 江川县| 分宜县| 建德市| 镇安县| 花莲市| 西昌市| 腾冲县| 永泰县| 于都县| 襄垣县| 静宁县| 道孚县|