Skip to content

Latest commit

 

History

History
66 lines (48 loc) · 969 Bytes

[0203] 移除链表元素.md

File metadata and controls

66 lines (48 loc) · 969 Bytes
title tags categories author comments updated permalink mathjax top description date
[0203] 移除链表元素
leetcode
leetcode
张学志
true
false
false
false
...
2019-12-31 16:03:23 -0800

题目描述

删除链表中等于给定值 val 的所有节点。

示例:

输入: 1->2->6->3->4->5->6, val = 6
输出: 1->2->3->4->5
Related Topics
  • 链表
  • 题目代码

    /**
     * Definition for singly-linked list.
     * struct ListNode {
     *     int val;
     *     ListNode *next;
     *     ListNode(int x) : val(x), next(NULL) {}
     * };
     */
    class Solution {
    public:
        ListNode* removeElements(ListNode* head, int val) {
    
        }
    };

    题目解析

    方法一

    方法二

    方法三