正文
1、LeetCode上用 方法里返回值用 return ,不能用print(),导致编译错误 2、相同的代码在LeetCode上能运行,但是在pycharm上不行,为什么??
class Solution
:
# def deleteDuplicates(self,head):
def
deleteDuplicates(self
, head
: ListNode
) -> ListNode
:
# head is None
if not head
:
# print(None)
return None
cur_list
= head
while cur_list
.next
:
if cur_list
.val
== cur_list
.next
.val
:
cur_list
.next
= cur_list
.next
.next
else:
cur_list
= cur_list
.next #
# print(head)
return head
LeetCode上只要写关键部分,输入,函数调用等部分没有显示。 可在下面的额红色部分得到完整的LeetCode代码,即playground
添加要改颜色的字体
添加要改颜色的字体
添加要改颜色的字体
添加要改颜色的字体