Skip to content

Commit

Permalink
πŸ‘¨β€πŸ”§ SwiftLint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jobearrr committed Jul 20, 2024
1 parent bb9fbae commit 725bd7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ final class LongestSubstringWithUniqueCharsOptimizedSlidingWindowSolution: Longe
var indexArray = Array(repeating: -1, count: 128)
var maxLength = 0
var start = 0

let chars = Array(s)

for i in 0..<chars.count {
guard let asciiValue = chars[i].asciiValue else { continue }
let asciiIndex = Int(asciiValue)

if indexArray[asciiIndex] != -1 {
start = max(start, indexArray[asciiIndex] + 1)
}

indexArray[asciiIndex] = i
maxLength = max(maxLength, i - start + 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ final class MedianOfTwoSortedArraysBinarySearchSolution: MedianOfTwoSortedArrays
let b = nums1.count < nums2.count ? nums2 : nums1
let m = a.count
let n = b.count

var low = 0
var high = m

while low <= high {
let i = (low + high) / 2
let j = (m + n + 1) / 2 - i

let maxLeftA = (i == 0) ? Int.min : a[i - 1]
let minRightA = (i == m) ? Int.max : a[i]

let maxLeftB = (j == 0) ? Int.min : b[j - 1]
let minRightB = (j == n) ? Int.max : b[j]

if maxLeftA <= minRightB && maxLeftB <= minRightA {
if (m + n) % 2 == 0 {
return Double(max(maxLeftA, maxLeftB) + min(minRightA, minRightB)) / 2.0
Expand All @@ -42,7 +42,7 @@ final class MedianOfTwoSortedArraysBinarySearchSolution: MedianOfTwoSortedArrays
low = i + 1
}
}

return 0.0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ final class MedianOfTwoSortedArraysMergeSolution: MedianOfTwoSortedArraysDefinit

func findMedianSortedArrays(_ nums1: [Int], _ nums2: [Int]) -> Double {
let mergedArray = (nums1 + nums2).sorted()

let mid = mergedArray.count / 2

if mergedArray.count % 2 == 1 {
return Double(mergedArray[mid])
}
Expand Down

0 comments on commit 725bd7e

Please sign in to comment.