Re: [閒聊] 每日leetcode

作者: sustainer123 (caster)   2024-05-05 11:56:56
※ 引述《SecondRun (南爹摳打)》之銘言:
: 237.刪除linked list裡的一個node
: input只會給要刪除的node
: 想法:
: 沒辦法把上一個node直接接到下一個node
: 那就把要刪除的node資料換成下一個node的
: C# code
: public class Solution {
: public void DeleteNode(ListNode node) {
: node.val = node.next.val;
: node.next = node.next.next;
: }
: }
: 這也有medium
: 屋搜打囉
思路:
完全一樣
Python Code:
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteNode(self, node):
"""
:type node: ListNode
:rtype: void Do not return anything, modify node in-place instead.
"""
node.val = node.next.val
node.next = node.next.next
本來想說等cnn跑的時候 刷題耗個時間
結果今天好簡單 哇哇嗚嗚嗚
作者: wu10200512 (廷廷)   2024-05-05 11:57:00
大師
作者: edieedie (一代一代)   2024-05-05 11:58:00
挖操這三小
作者: DJYOSHITAKA (Evans)   2024-05-05 11:59:00
剩我不會了
作者: SecondRun (雨夜琴聲)   2024-05-05 12:14:00
大師
作者: JIWP (JIWP)   2024-05-05 13:14:00
別卷了

Links booklink

Contact Us: admin [ a t ] ucptt.com