Repository navigation
chapter_array_and_linkedlist/exercises/ #1949
Replies: 7 comments 1 reply
|
写了写代码,但感觉有点麻烦 class ListNode:
def __init__(self, value):
self.value = value
self.next = None
self.prev = None
def reverse(head: ListNode) -> ListNode:
prev = None
while head.next:
head.prev = prev
prev = head
head = head.next
head.prev = prev
while head.prev:
head.next = head.prev
head.prev = None
head = head.next
head.next = None
def print_list(head: ListNode):
arr = []
while head:
arr.append(head.value)
head = head.next
print(arr)
n0 = ListNode(1)
n1 = ListNode(3)
n2 = ListNode(2)
n3 = ListNode(5)
n4 = ListNode(4)
# link
n0.next = n1
n1.next = n2
n2.next = n3
n3.next = n4
n4.next = None
print_list(n0)
reverse(n0)
print_list(n4) |
|
这有一道大数加法???? |
|
class ListNode { |
|
class Solution { |
|
数组大整数+1好恶心,我靠,我暴力了半天过了一半的题解,发现数组长度最多是100,long也放不下
int cur = digits[i]; } |
|
反转链表做了好几遍了,还是分不清它最后返回的是prev还是head还是node /**
ListNode nextNode = node.next; } |
|
#include void printArray(int *arr,int size){ int * addOne(int *arr,int& size){ } int main(){ } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
chapter_array_and_linkedlist/exercises/
动画图解、一键运行的数据结构与算法教程
https://www.hello-algo.com/chapter_array_and_linkedlist/exercises/
All reactions