Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Append_Arrays
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> input = Console.ReadLine().Split('|').Select(int.Parse).ToList();
  14.             for (int i = input.Count - 1; i >= 0; i--)
  15.             {
  16.                 if (input[i] == null)
  17.                 {
  18.                     input.RemoveAt(i); // O(n)
  19.                 }
  20.             }
  21.             List <int> newList= new List<int>();
  22.             for (int i = input.Count - 1; i >= 0; i--)
  23.             {
  24.                 newList = input[i].ToList();
  25.                 foreach (var item in newList)
  26.                 {
  27.                     input.Add(item);
  28.                 }
  29.             }
  30.  
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement