C# Birthday Cake Candles [HackerRank]
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
class Result
{
public static int birthdayCakeCandles(List<int> candles)
{
//정수형 변수 선언, 가장 큰 값 변수, 카운트 변수
int max = candles.Max();
int count = 0;
//해당 리스트가 가장 큰 값이면 카운트 더하기
for(int i=0; i<candles.Count; i++)
{
if(candles[i]==max) count++;
}
return count;
}
}
class Solution
{
public static void Main(string[] args)
{
TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
int candlesCount = Convert.ToInt32(Console.ReadLine().Trim());
List<int> candles = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(candlesTemp => Convert.ToInt32(candlesTemp)).ToList();
int result = Result.birthdayCakeCandles(candles);
textWriter.WriteLine(result);
textWriter.Flush();
textWriter.Close();
}
}
'개발공간' 카테고리의 다른 글
C# Apple and Orange [HackerRank] (0) | 2021.09.09 |
---|---|
C# Time Conversion [HackerRank] (0) | 2021.08.31 |
C# Mini-Max Sum [HackerRank] (0) | 2021.08.31 |
C# Staircase [HackerRank] (0) | 2021.08.31 |
C# Plus Minus [HackerRank] (0) | 2021.08.31 |
댓글