Re: [閒聊] 每日leetcode已回收
看板Marginalman作者sustainer123 (caster )時間1年前 (2024/05/05 11:56)推噓3(3推 0噓 2→)留言5則, 5人參與討論串187/1548 (看更多)
※ 引述《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跑的時候 刷題耗個時間
結果今天好簡單 哇哇嗚嗚嗚
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.43.133.194 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1714881419.A.48F.html
推
05/05 11:57,
1年前
, 1F
05/05 11:57, 1F
推
05/05 11:58,
1年前
, 2F
05/05 11:58, 2F
→
05/05 11:59,
1年前
, 3F
05/05 11:59, 3F
推
05/05 12:14,
1年前
, 4F
05/05 12:14, 4F
→
05/05 13:14,
1年前
, 5F
05/05 13:14, 5F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 187 之 1548 篇):