Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2. namespace TestApplication
  3. {
  4. internal class Program
  5. {
  6.     private static void Main(string[] args)
  7.     {
  8.         var array = new[] {1, 5, 2, 2, 2, 2, 4, 5, 5, 5, 1, 1, 2, 5};
  9.         int maxStreak = 0, curStreak = 0;
  10.  
  11.         for (var i = 1; i < array.Length; i++)
  12.         {
  13.             if (array[i] == array[i - 1]) curStreak++;
  14.             else
  15.             {
  16.                 if (curStreak >= maxStreak) maxStreak = curStreak;
  17.                 curStreak = 0;
  18.             }
  19.         }
  20.  
  21.         Console.WriteLine(maxStreak);
  22.     }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement