solution.json 2.3 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "c999971e21ad43e3aae8542f7740dd5c",
  "keywords": "哈希表,字符串,滑动窗口",
  "title": "无重复字符的最长子串",
  "desc": [
    {
      "content": "\n<p>给定一个字符串,请你找出其中不含有重复字符的 <strong>最长子串 </strong>的长度。</p><p> </p><p><strong>示例 1:</strong></p><pre><strong>输入: </strong>s = \"abcabcbb\"<strong><br />输出: </strong>3 <strong><br />解释:</strong> 因为无重复字符的最长子串是 \"abc\",所以其长度为 3。</pre><p><strong>示例 2:</strong></p><pre><strong>输入: </strong>s = \"bbbbb\"<strong><br />输出: </strong>1<strong><br />解释: </strong>因为无重复字符的最长子串是 \"b\",所以其长度为 1。</pre><p><strong>示例 3:</strong></p><pre><strong>输入: </strong>s = \"pwwkew\"<strong><br />输出: </strong>3<strong><br />解释: </strong>因为无重复字符的最长子串是 \"wke\",所以其长度为 3。 \n请注意,你的答案必须是 <strong>子串 </strong>的长度,\"pwke\" 是一个<em>子序列,</em>不是子串。</pre><p><strong>示例 4:</strong></p><pre><strong>输入: </strong>s = \"\"<strong><br />输出: </strong>0</pre><p> </p><p><strong>提示:</strong></p><ul>\t<li><code>0 <= s.length <= 5 * 10<sup>4</sup></code></li>\t<li><code>s</code> 由英文字母、数字、符号和空格组成</li></ul>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "int hset[128];\nint lengthOfLongestSubstring(char *s)\n{\n\tint i = 0, j = 0;\n\tint m = 0;\n\tmemset(hset, 0, sizeof hset);\n\tfor (; s[j]; j++)\n\t{\n\t\ti = hset[s[j]] > i ? hset[s[j]] : i;\n\t\tm = m > j - i + 1 ? m : j - i + 1;\n\t\thset[s[j]] = j + 1;\n\t}\n\treturn m;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-5916246072a346c986fd14202099c13e",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600471011"
}