Created
May 6, 2020 05:00
-
-
Save DongguemYoo/0b780bb1b1ab202ba577237482884a2a to your computer and use it in GitHub Desktop.
코딩테스트 연습 예산.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1분컷 | |
using System; | |
public class Solution { | |
public int solution(int[] d, int budget) | |
{ | |
int answer = 0; | |
Array.Sort(d); | |
for (int i = 0; i < d.Length; i++) | |
{ | |
budget -= d[i]; | |
if (budget >= 0) | |
answer++; | |
else | |
break; | |
} | |
return answer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment