diff --git a/Sources/Solutions/003 - Longest Substring Without Repeating Characters/LongestSubstringWithoutRepeatingCharactersBruteForceSolution.swift b/Sources/Solutions/003 - Longest Substring Without Repeating Characters/LongestSubstringWithoutRepeatingCharactersBruteForceSolution.swift new file mode 100644 index 0000000..b99329e --- /dev/null +++ b/Sources/Solutions/003 - Longest Substring Without Repeating Characters/LongestSubstringWithoutRepeatingCharactersBruteForceSolution.swift @@ -0,0 +1,31 @@ +// +// LongestSubstringWithoutRepeatingCharactersBruteForceSolution.swift +// LeetSwift +// +// Created by Jobert on 10/07/2024. +// + +import Core +import Foundation +import Problems + +final class LongestSubstringWithoutRepeatingCharactersBruteForceSolution: LongestSubstringWithoutRepeatingCharactersDefinition { + + func lengthOfLongestSubstring(_ s: String) -> Int { + let chars = Array(s) + var maxLength = 0 + + for i in 0..() + for j in i.. Int { - return -1 - } -} diff --git a/Tests/SolutionsTests/003 - Longest Substring Without Repeating Characters/LongestSubstringWithoutRepeatingCharactersSolutionTests.swift b/Tests/SolutionsTests/003 - Longest Substring Without Repeating Characters/LongestSubstringWithoutRepeatingCharactersSolutionTests.swift index 597f093..1659d67 100644 --- a/Tests/SolutionsTests/003 - Longest Substring Without Repeating Characters/LongestSubstringWithoutRepeatingCharactersSolutionTests.swift +++ b/Tests/SolutionsTests/003 - Longest Substring Without Repeating Characters/LongestSubstringWithoutRepeatingCharactersSolutionTests.swift @@ -12,7 +12,7 @@ import XCTest final class LongestSubstringWithoutRepeatingCharactersSolutionTests: XCTestCase { - let solution: LongestSubstringWithoutRepeatingCharactersDefinition = LongestSubstringWithoutRepeatingCharactersSolution() + let solution: LongestSubstringWithoutRepeatingCharactersDefinition = LongestSubstringWithoutRepeatingCharactersBruteForceSolution() func testSolution() { for testData in data {