Advertisement
alexbancheva

Replace Repeating Chars_Text_Processing

Sep 14th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ReplaceRepeatingChars_ExeTextProcessing
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var input = Console.ReadLine().ToList();
  12.  
  13.             for (int i = 0; i < input.Count - 1; i++)
  14.             {
  15.                 char current = input[i];
  16.                 char next = input[i + 1];
  17.  
  18.                 if (current == next)
  19.                 {
  20.                     input.RemoveAt(i);
  21.                     i--;
  22.                 }
  23.             }
  24.  
  25.             Console.WriteLine(string.Join("", input));
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement