small update to LeetCode

This commit is contained in:
cediackermann 2026-06-13 00:03:36 +02:00
parent 160eb549e0
commit b71f6978f1
No known key found for this signature in database

View file

@ -14,7 +14,7 @@ enum LeetCode {
} }
static func sortedSquares(_ nums: [Int]) -> [Int] { static func sortedSquares(_ nums: [Int]) -> [Int] {
nums.map { $0 $0 }.sorted() nums.map { $0 * $0 }.sorted()
} }
static func productExceptSelf(_ nums: [Int]) -> [Int] { static func productExceptSelf(_ nums: [Int]) -> [Int] {
@ -47,16 +47,23 @@ enum LeetCode {
} }
} }
public class TreeNode {
public class TreeNode { public var val: Int
public var val: Int public var left: TreeNode?
public var left: TreeNode? public var right: TreeNode?
public var right: TreeNode? public init() {
public init() { self.val = 0; self.left = nil; self.right = nil; } self.val = 0
public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; } self.left = nil
public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) { self.right = nil
self.val = val }
self.left = left public init(_ val: Int) {
self.right = right self.val = val
} self.left = nil
} self.right = nil
}
public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {
self.val = val
self.left = left
self.right = right
}
}