ListNode *access(ListNode *head, int index)
{
while(head && head -> next && index)
{
head = head -> next;
index --;
}
return head;
}
int find(ListNode *head, int target)
{
int index = 0;
while(head){
if(head -> val == target)
return index;
head = head -> next;
index ++;
}
return -1;
}
Access and Find
最新推荐文章于 2024-09-05 11:00:53 发布