ITPub博客

首页 > IT职业 > IT职场 > LeetCode 3

LeetCode 3

IT职场 作者:fengwei 时间:2021-09-09 10:21:24 0 删除 编辑

Longest Substring Without Repeating Characters

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

Example 1:

Input: "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.

简述:统计字符串不重复字符最长子串的长度。

C语言实现

使用两个下标i,index。i作为字符串的下标,依次往下移动。index为子串的下标往右移动。index+i是在母串移动的位置。
初始化子串p比母串大1,不然有的编译器报越界。每次赋值后给下一位赋值'

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2799/viewspace-2820899/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-16

  • 博文量
    90
  • 访问量
    675