[go: nahoru, domu]

Skip to content

Commit

Permalink
Update 3_LongestSubstringWithoutRepeatingCharacters
Browse files Browse the repository at this point in the history
  • Loading branch information
Wang Xingbin committed Sep 21, 2020
1 parent d019889 commit 6e43c05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import Foundation
//
// 3. 无重复字符的最长子串
//
// 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。
//
// 题目链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/
// 标签:哈希表、双指针、字符串、滑动窗口
// 要点:前后双指针,滑动窗口,计算最大值
// 时间复杂度:O(N)
// 空间复杂度:O(k), k = min(m, n)
//

/// 前后双指针
class Solution {
func lengthOfLongestSubstring(_ s: String) -> Int {

Expand Down Expand Up @@ -39,6 +42,7 @@ class Solution {
}
}

/// 滑动窗口
class Solution2 {
func lengthOfLongestSubstring(_ s: String) -> Int {

Expand All @@ -61,6 +65,7 @@ class Solution2 {
}
}

/// 计算最大值
class Solution3 {
func lengthOfLongestSubstring(_ s: String) -> Int {

Expand Down
5 changes: 5 additions & 0 deletions String/3_LongestSubstringWithoutRepeatingCharacters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
//
// 3. 无重复字符的最长子串
//
// 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。
//
// 题目链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/
// 标签:哈希表、双指针、字符串、滑动窗口
// 要点:前后双指针,滑动窗口,计算最大值
// 时间复杂度:O(N)
// 空间复杂度:O(k), k = min(m, n)
//

/// 前后双指针
class Solution {
func lengthOfLongestSubstring(_ s: String) -> Int {

Expand Down Expand Up @@ -36,6 +39,7 @@ class Solution {
}
}

/// 滑动窗口
class Solution2 {
func lengthOfLongestSubstring(_ s: String) -> Int {

Expand All @@ -58,6 +62,7 @@ class Solution2 {
}
}

/// 计算最大值
class Solution3 {
func lengthOfLongestSubstring(_ s: String) -> Int {

Expand Down

0 comments on commit 6e43c05

Please sign in to comment.