假设给定链表为: ,若调用 searchValue(head, 5) ,函数返回值为( )。
int searchValue(ListNode* head, int target) {\twhile (head != nullptr) {\t\tif (head->val == target) {\t\t\treturn 1;\t\t}\t\thead = head->next;\t}\treturn 0;}
返回 1
返回 0
死循环,无法返回
返回 -1
微信小程序
微信扫一扫体验
微信公众账号
微信扫一扫加关注
发表评论 取消回复