Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _23UniqueLetters
- {
- class UniqueLetters
- {
- static void Main(string[] args)
- {
- string sample = "ala bala nica, ABBA aaaaaataka boobs mississippi";
- StringBuilder sb = new StringBuilder();
- char lastAppended = char.MinValue;
- for (int i = 0; i < sample.Length; i++)
- {
- char currentSymbol = sample[i];
- if (('a' <= currentSymbol || currentSymbol <= 'z') || ('A' <= currentSymbol || currentSymbol <= 'Z'))
- {
- if (currentSymbol != lastAppended)
- {
- sb.Append(currentSymbol);
- lastAppended = currentSymbol;
- }
- }
- else
- {
- sb.Append(currentSymbol);
- }
- }
- Console.WriteLine(sb.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement