Files
Yudong Jin 772183705e Add ru version (#1865)
* Add Russian docs site baseline

* Add Russian localized codebase

* Polish Russian code wording

* Update ru code translation.

* Update code translation and chapter covers.

* Fix pythontutor extraction.

* Add README and landing page.

* placeholder of profiles

* Use figures of English version

* Remove chapter paperbook
2026-03-28 04:24:07 +08:00

34 lines
908 B
Swift

/**
* File: ListNode.swift
* Created Time: 2023-01-02
* Author: nuomi1 (nuomi1@qq.com)
*/
public class ListNode: Hashable {
public var val: Int // Значение узла
public var next: ListNode? // Ссылка на узел-преемник
public init(x: Int) {
val = x
}
public static func == (lhs: ListNode, rhs: ListNode) -> Bool {
lhs.val == rhs.val && lhs.next.map { ObjectIdentifier($0) } == rhs.next.map { ObjectIdentifier($0) }
}
public func hash(into hasher: inout Hasher) {
hasher.combine(val)
hasher.combine(next.map { ObjectIdentifier($0) })
}
public static func arrToLinkedList(arr: [Int]) -> ListNode? {
let dum = ListNode(x: 0)
var head: ListNode? = dum
for val in arr {
head?.next = ListNode(x: val)
head = head?.next
}
return dum.next
}
}