C# Program to remove duplicate characters from a string

C# Program to remove duplicate characters from a string

Interview Point

3 года назад

16,726 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@manateshparit1596
@manateshparit1596 - 21.03.2023 23:22

Sir please give me this problem solution without taking contain method

Ответить
@MynamedidntFitDonkey
@MynamedidntFitDonkey - 30.03.2022 16:37

Thank you

Ответить
@osr2004snd
@osr2004snd - 29.12.2021 23:03

Simple:
string str = "Something @to ,Write.;';";
str = string.Join("", str.Split('@', ',', '.', ';', '\''));

Ответить
@KillerMindawg
@KillerMindawg - 20.12.2021 03:40

But string.contains is O(n)
So this algorithm is O(n^2)

Also space complexity should be improved by using string builder otherwise a new string is created on every new character.

Ответить