File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,14 @@ function solution(land) {
16
16
/* 풀이 과정
17
17
1. land의 행만큼 반복문을 돌린다.
18
18
2. i행(두번째 행)부터 land.length - 1행(마지막 행)까지 본인 열을 제외한 나머지 열의 최댓값을 본인의 열에 더하여 누적한다.
19
- 3. 마지막까지 다 구하면 마지막 행에서 최대값을 반환한다.*/
19
+ 3. 마지막까지 다 구하면 마지막 행에서 최대값을 반환한다.*/
20
+
21
+ //정답 2 - codeisneverodd
22
+ function solution ( land ) {
23
+ for ( let rowIndex = 1 ; rowIndex < land . length ; rowIndex ++ ) {
24
+ for ( let colIndex = 0 ; colIndex < land [ 0 ] . length ; colIndex ++ ) {
25
+ land [ rowIndex ] [ colIndex ] += Math . max ( ...land [ rowIndex - 1 ] . slice ( 0 , colIndex ) , ...land [ rowIndex - 1 ] . slice ( colIndex + 1 ) )
26
+ }
27
+ }
28
+ return Math . max ( ...land [ land . length - 1 ] )
29
+ }
Original file line number Diff line number Diff line change
1
+ //https://github.com/codeisneverodd/programmers-coding-test
2
+ //완벽한 정답이 아닙니다.
3
+ //정답 1 - codeisneverodd
4
+
5
+ function solution ( n , a , b ) {
6
+ let currentRound = 1 ;
7
+ const myNextNumber = ( num ) => Math . floor ( ( num + 1 ) / 2 ) //내가 이긴경우 다음으로 가지게 될 번호
8
+ while ( a !== b ) { // a의 다음 번호가 b의 다음번호와 같아지면 끝난다.
9
+ if ( myNextNumber ( a ) === myNextNumber ( b ) ) break
10
+ a = myNextNumber ( a )
11
+ b = myNextNumber ( b )
12
+ currentRound ++
13
+ }
14
+ return currentRound
15
+ }
You can’t perform that action at this time.
0 commit comments