s0160
This commit is contained in:
@@ -1 +1,22 @@
|
||||
# 总结
|
||||
|
||||
首先考虑递归 (e.g. s0206, s0024)
|
||||
|
||||
其次考虑双指针 (e.g. s0206, s0019, s0160)
|
||||
|
||||
递归遍历单链表:
|
||||
|
||||
```cpp
|
||||
void iter(ListNode *node) {
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
your
|
||||
condition
|
||||
*/
|
||||
iter(node->next);
|
||||
}
|
||||
```
|
||||
|
||||
递归遍历的意义在于让回溯单链表,也就是先遍历到结尾,然后从后往前遍历到某个 condition 。
|
||||
|
Reference in New Issue
Block a user