摘要: 这个题目直接递归就行,难度不大,就是要考虑全面一些哦,这道题应该也是剑指offer的原题 ,复习一下,挺简单的,代码如下: # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left= 阅读全文
posted @ 2021-08-31 23:41 Geeksongs 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 题目如下: 本题目的精华在于不要用一个for循环遍历整个linked list,而是使用两个for或者三个for对同一个linked list从前到后进行遍历,同样也只遍历O(the number of nodes)=O(N)次,我尝试过仅使用一个while循环来写,虽然也是o(n),但是在穿针引线 阅读全文
posted @ 2021-08-31 23:26 Geeksongs 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 题目如下: 本题目可以引入两个变量,一个变量pre,一个变量instant,这两个既是变量,也是指针,我们用head指针不断往后进行移动,每往后移动一次,instant变量就保存当前head的指针,然后instant.next指向pre指针 ,然后将instant的地址赋予pre指针,这样pre就做 阅读全文
posted @ 2021-08-31 22:46 Geeksongs 阅读(13) 评论(0) 推荐(0) 编辑

Coded by Geeksongs on Linux

All rights reserved, no one is allowed to pirate or use the document for other purposes.