
Leetcode经典题,C++、Python双解
文章平均质量分 50
Marvelous ヽ
练习英语,语法不对望指正。
展开
-
Day4:Leetcode-92. Reverse Linked List
Sloution 1: # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseBetween(self, head: ListNode, left: int, right: int) -.原创 2021-09-22 20:18:39 · 147 阅读 · 1 评论 -
Day3:Leetcode-206. Reverse Linked List
In a linknode list,we define a = list(),then we add some nodes,if we write a[0].next = a[1], that's fine ,it works, but when we turn to a[1].next = a[0],it time exceed,which confused me a lot. But finally I solved it. because,if we say a[1].next = a[0]...原创 2021-09-20 20:21:00 · 162 阅读 · 0 评论 -
Day2:Leetcode-83.Remove Duplicates from Sorted List
Solution 1: It is a sorted linked list, we can delete all duplicates one by one,but at first I made a mistake in case [0,0,0,0,0] , because I set pre number 0,therefore I turn it to be -99,that is okay. class Solution { public: ListNode* deleteDu.原创 2021-09-19 19:57:17 · 175 阅读 · 0 评论 -
Day1:Leetcode-19.Remove Nth Node From End of List
Tips:There is something noteworthy in C++ code,function getlen(LinkList * head),this formal parameteris fake,if we call thisfuntion,ouractual parameter head will not change。That is different from array,for instance int fun(int a[]),it will change our a...原创 2021-09-18 21:49:11 · 229 阅读 · 0 评论