You are viewing a single comment's thread. Return to all comments →
Please let me know what you think of my code in C#.
using System; using System.Collections.Generic; using System.IO; using System.Linq; public class Solution { #region Private Property /// <summary> /// Gets or sets the Length. /// </summary> private static int Length { get; set; } #endregion #region Methods /// <summary> /// Returns the Max count of birds. /// </summary> /// <param name='arr'></param> private static String migratoryBirds(String[] arr) { // Complete this function return arr.GroupBy(a => a).Select(b => new{ Bird = b.Key, Count = b.Count() }).OrderByDescending(c => c.Count).ThenBy(d => d.Bird).FirstOrDefault().Bird; } #endregion public static void Main(String[] args) { Length = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(migratoryBirds(Console.ReadLine().Split(' '))); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
Please let me know what you think of my code in C#.