pytudes._2021.utils.linked_listο
https://www.educative.io/courses/grokking-the-coding-interview/N7rwVyAZl6D
Module Contentsο
Classesο
Notes: |
Functionsο
|
Utility fn for easier testing |
Attributesο
- class pytudes._2021.utils.linked_list.ListNode(val, next_node=None)[source]ο
- Notes:
- βNodeTypeβ is a forward reference
Forward reference syntax: annotation as a string literal See Also: https://www.python.org/dev/peps/pep-0484/#id28
- Parameters:
val (Any) β
next_node (NodeType) β
- pytudes._2021.utils.linked_list.convert_list_to_linked_list(arr, recursive=False)[source]ο
Utility fn for easier testing
- Args:
arr: input array of elements to convert recursive: whether or not to perform conversion recursively
- Returns:
The head of the linked list derived from arr
- Examples:
>>> convert_list_to_linked_list([2,4,6,8,10], recursive=False).as_list() [2, 4, 6, 8, 10] >>> convert_list_to_linked_list([2,4,6,8,10], recursive=True).as_list() [2, 4, 6, 8, 10] >>> assert(convert_list_to_linked_list([]) is None)
- Parameters:
arr (list[Any]) β
- Return type:
NodeType
- pytudes._2021.utils.linked_list.NodeTypeο