Skip to content

14368: 【原4368】Remove Duplicate Elements

题目

题目描述

author: Mighty_A 原OJ链接:https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4368

Description

Given a linked list, remove the duplicate elements so that no neighboring elements are the same.
There are three types of elements:
0: int
1: char (lower and upper case character) 2: string (const char *)
Please use Class Template to implement the LinkedNode class. Also, your code are required to avoid memory lead. (TAs will check your code, so solutions without class template cannot get full score) Tip: to compare the different types, you may need Overloaded Functions. or Template Functions. If you have forgotten this knowledge, please refer to your programming textbook.

Permissible libraries:
iostream
cstdio
cstring
cmath

Input Format

Line 1: two numbers $k$ and $n$

Line 2: $n$ elements of type $k$

Output Format

Line 1: elements of the processed linked list, separated by space.

Input Sample 1

0 5

1 2 2 4 4

Output Sample 1

1 2 4

Input Sample 2

2 6

cat dog dog dog fish fish

Output Sample 2

cat dog fish

Limits

k = 0, 1, 2​

1 <= n <= 100000​

1 <= int elements <= 100000​

1 <= length of string <= 10

Oops! 本题目还没有解答!

助教老师们编题的速度,已经超过了解题的速度!

OJ翻了一新,但本解答集还大多用的是2017-2019级,甚至更早的同学们贡献的答案。

如果你已经AC了,可以的话,请您参考添加页面,与大家一起分享你的题解!