Skip to content

Commit ecf79f7

Browse files
committed
issue #28 Marc's Cakewalk java
1 parent 41c32a4 commit ecf79f7

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/hackerrank/MarcsCakewalk.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ static long marcsCakewalk(int[] calorie) {
88
//마크는 칼로리 c만큼인 컵케익 j를 행복하게 먹은 뒤 해당 칼로리를 불태우기위해 2의 j승 * c 마일만큼 걸으려고한다.
99
//그가 걸어야 하는 마일수 중 가장 작은 마일수를 리턴하는 문제.
1010

11-
//int[]는 Collections이 아니므로 Integer[]로 변경
11+
// 역순정렬을 하면 가장 작은 마일 수를 얻을 수 있다.
12+
// int[]는 Collections 메서드를 사용할 수 없으므로 Integer[]로 변경
1213
Integer[] caloriesInteger = new Integer[calorie.length];
1314
for(int i=0; i< calorie.length; i++){
1415
caloriesInteger[i] = calorie[i];
1516
}
16-
Arrays.sort(caloriesInteger, Collections.reverseOrder());
17+
Arrays.sort(caloriesInteger, Collections.reverseOrder()); //역순정렬
1718
System.out.println(Arrays.toString(caloriesInteger));
1819

1920
//가장 작은 마일수 구하기

0 commit comments

Comments
 (0)