File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ function solution ( num_list , n ) {
2+ return num_list . slice ( [ n - 1 ] ) ;
3+ }
Original file line number Diff line number Diff line change 1+ function solution ( n ) {
2+ for ( let x = 2 ; x < n ; x ++ ) {
3+ if ( n % x === 1 ) {
4+ return x ;
5+ }
6+ }
7+ }
8+
9+ // 다른 풀이
10+ // function solution(n, x = 1) {
11+ // while (x++) {
12+ // if (n % x === 1) {
13+ // return x;
14+ // }
15+ // }
16+ // }
Original file line number Diff line number Diff line change 1+ function solution ( num_list ) {
2+ for ( i = 0 ; i < num_list . length ; i ++ ) {
3+ if ( num_list [ i ] < 0 ) {
4+ return i ;
5+ }
6+ }
7+ return - 1 ;
8+ }
9+
10+ // 다른 풀이
11+ // const solution = num_list => num_list.findIndex(v => v < 0)
12+
13+ // function solution(num_list) {
14+ // let a = num_list.filter(c=> {if(c<0) return c})
15+ // return num_list.indexOf(a[0])
16+ // }
You can’t perform that action at this time.
0 commit comments