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 LongestNonDecreasingSubsequence
- {
- class LongestNonDecreasingSubsequence
- {
- static void Main(string[] args)
- {
- string[] sentence = Console.ReadLine().Split();
- int[] array = new int[sentence.Length];
- List<string> final = new List<string>();
- for (int i = 0; i < sentence.Length; i++)
- {
- for (int h = 0; h < sentence.Length; h++)
- {
- List<string> temp = new List<string>();
- List<string> temp2 = new List<string>();
- temp.Add(sentence[h]);
- temp2.Add(sentence[h]);
- string letter = sentence[h];
- string letter2 = sentence[h];
- for (int j = h + 1; j < sentence.Length; j++)
- {
- if (sentence[i] == sentence[j])
- {
- continue;
- }
- else if (int.Parse(letter) < int.Parse(sentence[j].ToString()))
- {
- letter = sentence[j];
- temp.Add(sentence[j]);
- }
- else if (int.Parse(letter2) == int.Parse(sentence[j].ToString()))
- {
- letter2 = sentence[j];
- temp2.Add(sentence[j]);
- }
- else
- {
- continue;
- }
- }
- if (temp.Count > final.Count)
- {
- final = temp;
- }
- else if (temp2.Count > final.Count)
- {
- final = temp2;
- }
- else
- {
- continue;
- }
- }
- }
- foreach (var item in final)
- {
- Console.Write(item + " ");
- }
- //unfinished
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement