错误如下:当测试案列是[ ]的时候解决办法:将错误处改为if (head == NULL || head->next == NULL)
原因:由于或和与具有短路效应,左边为真,则直接不判断,当输入为空的时候,null->next不存在,所以报错在。
Leetcode 206 runtime error: member access within null pointer of type
于 2022-11-17 11:37:07 首次发布
错误如下:当测试案列是[ ]的时候解决办法:将错误处改为if (head == NULL || head->next == NULL)
原因:由于或和与具有短路效应,左边为真,则直接不判断,当输入为空的时候,null->next不存在,所以报错在。