
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
A small Python 3.5+ library to make debugging LeetCode binary tree, linked list and matrix problems more convenient.
A small Python 3.5+ library to make debugging LeetCode binary tree, linked list and matrix problems more convenient.
from leetnode import TreeNode, build_btree
btree_node = TreeNode('val')
btree1 = build_btree([3, 9, 20, 8, 16, 15, 7, 1, 2, None, None, 3, None, None, None, None, None, 12])
or
btree2 = TreeNode.from_list(['a', 'b', 'cd', None, 'ef', 'gh', 'i', None, None, None, None, 'jkl', 'mn', 'o'])
or, from a JSON string
btree3 = TreeNode.from_list('[1, null, 555555, null, 43, 1]')
>>> print(btree1)
[3, 9, 20, 8, 16, 15, 7, 1, 2, None, None, 3, None, None, None, None, None, 12]
>>> print(btree2)
['a', 'b', 'cd', None, 'ef', 'gh', 'i', None, None, None, None, 'jkl', 'mn', 'o']
>>> print(btree3)
[1, None, 555555, None, 43, 1]
>>> print(btree1.tree_string())
___3_____
/ \
_____9 _20
/ \ / \
8___ 16 15 7
/ \ /
1 _2 3
/
12
>>> print(btree2.tree_string())
______'a'______
/ \
'b'_ __'cd'___________
\ / \
'ef' 'gh' __'i'_
/ \
_'jkl' 'mn'
/
'o'
>>> print(btree3.tree_string())
1__
\
555555__
\
43
/
1
from leetnode import ListNode, build_linked_list
list_node = ListNode('val')
llist1 = build_linked_list(['a', 'b', 'c', 'd'])
or
llist2 = ListNode.from_list([1, 2, 3, 4, 5])
or, from a JSON string
llist3 = ListNode.from_list('["e", "f", "g", "h"]')
>>> print(llist1)
['a' -> 'b' -> 'c' -> 'd']
>>> print(llist2)
[1 -> 2 -> 3 -> 4 -> 5]
>>> print(llist3)
['e' -> 'f' -> 'g' -> 'h']
>>> for node in llist1:
... print(node.val + node.next.val if node.next is not None else node.val)
...
ab
bc
cd
d
>>> mat1 = [[1.2, 2.33, 3.0], [4.5, 6.7777, 8], [9.0, 10.98, 111.42]]
>>> mat2 = [[3, 0, 8, 4], [2, 2340, 5, 7], [97, 432, 6, 3], [0, 3, 1, 13]]
>>> mat3 = mat3 = '[["a", "b", "ccc"], ["dd", "e", "ff"], ["g", "h", "i"]]'
>>> print(matrix_to_string(mat1))
[ [ 1.2 , 2.33 , 3.0 ],
[ 4.5 , 6.7777, 8 ],
[ 9.0 , 10.98 , 111.42 ] ]
>>> print(matrix_to_string(mat2))
[ [ 3, 0, 8, 4 ],
[ 2, 2340, 5, 7 ],
[ 97, 432, 6, 3 ],
[ 0, 3, 1, 13 ] ]
>>> print(matrix_to_string(mat3))
[ [ 'a' , 'b' , 'ccc' ],
[ 'dd' , 'e' , 'ff' ],
[ 'g' , 'h' , 'i' ] ]
FAQs
A small Python 3.5+ library to make debugging LeetCode binary tree, linked list and matrix problems more convenient.
We found that leetnode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.