mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
feat: add Swift codes for chapter_searching articles (#309)
* feat: add Swift codes for linear_search article * feat: add Swift codes for binary_search article * feat: add Swift codes for hashing_search article
This commit is contained in:
@ -11,4 +11,14 @@ public class ListNode {
|
||||
public init(x: Int) {
|
||||
val = x
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user