Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
FixConsectiveDuplicates
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Text; namespace Rextester { public class Program { public static void Main(string[] args) { // Free all bakery items for free on weekends // FREE free engine check and 5 other are live // string message = "FREE engine engine check check and 5 other other deals deals are deal deal live"; // Console.Write(string.Join(" ", message.ToLower().Split(' ').Distinct()).ToLowerInvariant()); FixConsectiveDuplicates(message); } public static string FixConsectiveDuplicates(string s) { StringBuilder sb = new StringBuilder(); var words = s.ToLower().Split(' '); string lastWord = string.Empty; foreach(string word in words) { // Console.WriteLine(word); if(!word.Equals(lastWord)) { sb.Append(word + " "); } lastWord = word; } Console.WriteLine(sb); return s; } } }
run
|
edit
|
history
|
help
0
code
C# .ToInt() Extension Method Example
concrete class with inheritance
test1
ö2
Selection Sort
Test Stopwatch
1 to 1000 armstrong
caleb
Ventmatika testas