摘要:
solution rescursive class Solution: def mirrorTree(self, root: TreeNode) -> TreeNode: def helper(node): if not node: return left = helper(node.left) r 阅读全文
摘要:
思路 dfs 注意注释掉的代表完全子树 class Solution: def isSubStructure(self, A: TreeNode, B: TreeNode) -> bool: def helper(a, b): # if not a and not b: # return True 阅读全文
摘要:
思路 递归 class Solution: def reverseList(self, head: ListNode) -> ListNode: def helper(head): if head is None or head.next is None: return head ret = hel 阅读全文
摘要:
描述 None tags: list, double pointer 思路 两次遍历 class Solution { public: ListNode* getKthFromEnd(ListNode* head, int k) { ListNode* node = head; int length 阅读全文
摘要:
描述 None tags: partition 思路 快排 class Solution(object): def exchange(self, nums): """ :type nums: List[int] :rtype: List[int] """ l, r = 0, len(nums) - 阅读全文
摘要:
描述 给定单向链表的头指针和一个要删除的节点的值,定义一个函数删除该节点。 返回删除后的链表的头节点。 tags: recursive, double pointer 思路 递归 class Solution { public: ListNode* deleteNode(ListNode* head 阅读全文