摘要:
自己写的,先整数转二进制,再切片二进制转16进制 class Solution: def toHex(self, num: int) -> str: # 处理特殊情况:当 num 为 0 时,直接返回 '0' if num == 0: return '0' # 定义十六进制字母的映射关系 my_di 阅读全文
posted @ 2024-04-23 16:40
Junior_bond
阅读(24)
评论(0)
推荐(0)
摘要:
自己写的,使用了经典的广度优先搜素(BFS): class Solution: def sumOfLeftLeaves(self, root: Optional[TreeNode]) -> int: # 初始化队列,将根节点放入队列中 queue = [root] # 初始化结果变量 res = 0 阅读全文
posted @ 2024-04-23 13:59
Junior_bond
阅读(26)
评论(0)
推荐(0)

浙公网安备 33010602011771号