diff --git a/longest-substring-without-repeating-characters/delight010.swift b/longest-substring-without-repeating-characters/delight010.swift new file mode 100644 index 000000000..aaac19f08 --- /dev/null +++ b/longest-substring-without-repeating-characters/delight010.swift @@ -0,0 +1,26 @@ +class Solution { + // Time complexity O(N) + // Space complexity O(min(m,n)) + func lengthOfLongestSubstring(_ s: String) -> Int { + if s.isEmpty { + return 0 + } + var maxLength = 0 + var startIndex = 0 + var charSet: Set = [] + let charArray = Array(s) + + for right in 0.. ListNode? { + var reverseList: ListNode? = nil + var currentHead = head + while let node = currentHead { + currentHead = node.next + node.next = reverseList + reverseList = node + } + return reverseList + } +} + diff --git a/set-matrix-zeroes/delight010.swift b/set-matrix-zeroes/delight010.swift new file mode 100644 index 000000000..472e41385 --- /dev/null +++ b/set-matrix-zeroes/delight010.swift @@ -0,0 +1,63 @@ +class Solution { + // Time complexity O(MN) + // Space complexity O(1) + func setZeroes(_ matrix: inout [[Int]]) { + var firstRowHasZero = false + var firstColHasZero = false + + for col in 0.. Int { + let column = Array(repeating: 1, count: n) + var grid: [[Int]] = Array(repeating: column, count: m) + for i in 1..