目录
一、删除排序列表中的重复元素
1、题目描述

2、题解

3、源码
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* deleteDuplicates(struct ListNode* head){
if (!head){
return head;
}
struct ListNode* cur = head;
while(cur->next) {
if(cur->val == cur->next->val) {
cur->next = cur->next->next;
}else {
cur = cur->next;
}
}
return head;
}
二、二叉树的最大深度
1、题目描述

2、题解

3、源码
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
int maxDepth(struct TreeNode *root) {
if (root == NULL) return 0;
return fmax(maxDepth
最低0.47元/天 解锁文章
1442

被折叠的 条评论
为什么被折叠?



