struct node {
int val;
node *next;
};
void deleteBetweenMaxAndMin(node *head, int minv, int maxv) {
node *p = head;
node *q = head->next;
node *premin = head, *premax = head;
node *pmin = head->next, *pmax = head->next;
bool flag = false;
bool tag = false;
while (q) {
if (q->val > minv && !flag) {
pmin = q;
premin = p;
flag = true;
} else if (q->val < maxv && !tag) {
pmax = q;
premax = p;
}
p = p->next;
q = q->next;
}
premin->next = pmax->next;
}
单链表:删除带头结点递增有序单链表中开区间(a,b)的所有节点
最新推荐文章于 2023-07-17 14:46:50 发布