-
Notifications
You must be signed in to change notification settings - Fork 4
[Juhee] 25.01.05 #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[Juhee] 25.01.05 #11
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a2c214b
배열 자르기 / 기초
juhee067 71b4e33
배열 원소의 길이 / 기초
juhee067 8124698
배열 회전시키기 / 기초
juhee067 fd20195
중복된 숫자 개수
juhee067 da0c162
제일 작은 수 제거하기
juhee067 5cc14eb
나누어 떨어지는 숫자 배열 / 중급
juhee067 35ac806
행렬의 덧셈 / 중급
juhee067 8f33c3f
행렬의 곱셉 / 심화
juhee067 85b3855
스택 설명
juhee067 eca8495
문자열 뒤집기 / 기초
juhee067 923ceb4
문자열 계산하기 / 기초
juhee067 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // 문자열 배열 strlist가 매개변수로 주어집니다. | ||
| // strlist 각 원소의 길이를 담은 배열을 return하도록 solution 함수를 완성해주세요. | ||
|
|
||
| function solution(strlist) { | ||
| return strlist.map((v) => v.length); | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // array의 각 element 중 divisor로 나누어 떨어지는 값을 오름차순으로 정렬한 배열을 반환하는 함수, solution을 작성해주세요. | ||
| // divisor로 나누어 떨어지는 element가 하나도 없다면 배열에 -1을 담아 반환하세요. | ||
|
|
||
| function solution(arr, divisor) { | ||
| const result = arr.filter((a) => a % divisor === 0).sort((a, b) => a - b); | ||
| return result.length === 0 ? [-1] : result; | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // 정수가 담긴 배열 array와 정수 n이 매개변수로 주어질 때, | ||
| // array에 n이 몇 개 있는 지를 return 하도록 solution 함수를 완성해보세요. | ||
|
|
||
| function solution(array, n) { | ||
| return array.filter((v) => v === n).length; | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| function solution(arr1, arr2) { | ||
| const row = arr1.length; | ||
| const col1 = arr1[0].length; | ||
| const col2 = arr2[0].length; | ||
| const answer = []; | ||
| const result = Array.from(Array(row), () => Array(col2).fill(0)); | ||
|
|
||
| for (let i = 0; i < row; i++) { | ||
| for (let j = 0; j < col2; j++) { | ||
| for (let k = 0; k < col1; k++) { | ||
| result[i][j] += arr1[i][k] * arr2[k][j]; | ||
| } | ||
| } | ||
| } | ||
| return result; | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // 행렬의 덧셈은 행과 열의 크기가 같은 두 행렬의 같은 행, 같은 열의 값을 서로 더한 결과가 됩니다. | ||
| // 2개의 행렬 arr1과 arr2를 입력받아, 행렬 덧셈의 결과를 반환하는 함수, solution을 완성해주세요. | ||
| function solution(arr1, arr2) { | ||
| const arr = arr1.length; | ||
| const element = arr1[0].length; | ||
| const result = []; | ||
| for (let i = 0; i < arr; i++) { | ||
| const row = []; | ||
| for (let j = 0; j < element; j++) { | ||
| row.push(arr1[i][j] + arr2[i][j]); | ||
| } | ||
| result.push(row); | ||
| } | ||
| return result; | ||
| } | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // 정수를 저장한 배열, arr 에서 가장 작은 수를 제거한 배열을 리턴하는 함수, solution을 완성해주세요. | ||
| // 단, 리턴하려는 배열이 빈 배열인 경우엔 배열에 -1을 채워 리턴하세요. | ||
| // 예를들어 arr이 [4,3,2,1]인 경우는 [4,3,2]를 리턴 하고, [10]면 [-1]을 리턴 합니다. | ||
|
|
||
| function solution(arr) { | ||
| if (arr.length <= 1) return [-1]; | ||
| const min = Math.min(...arr); | ||
| return arr.filter((v) => v !== min); | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // 정수가 담긴 배열 numbers와 문자열 direction가 매개변수로 주어집니다. | ||
| // 배열 numbers의 원소를 direction방향으로 한 칸씩 회전시킨 배열을 return하도록 solution 함수를 완성해주세요. | ||
|
|
||
| function solution(numbers, direction) { | ||
| if (direction === 'right') { | ||
| numbers.unshift(numbers.pop()); | ||
| } else { | ||
| numbers.push(numbers.shift()); | ||
| } | ||
| return numbers; | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // 정수 배열 numbers와 정수 num1, num2가 매개변수로 주어질 때, | ||
| // numbers의 num1번 째 인덱스부터 num2번째 인덱스까지 | ||
| // 자른 정수 배열을 return 하도록 solution 함수를 완성해보세요. | ||
| function solution(numbers, num1, num2) { | ||
| return numbers.slice(num1, num2 + 1); | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ### 스택의 의미 | ||
|
|
||
|  | ||
| | 쌓아 올린다는 것을 의미 | ||
|
|
||
| - 같은 구조와 크기의 자료를 정해진 방향으로만 쌓을 수 있다. | ||
| - top으로 정한 곳을 통해서만 접근 가능 | ||
| - 자료를 삭제할 때도 top을 통해서만 가능 | ||
| - top을 통해 삽입하는 연산 **PUSH** | ||
| - top을 통해 삭제하는 연산 **POP** | ||
| - 시간 순서에 따라 자료가 쌓여서 가장 마지막에 삽입된 자료가 가장 먼저 삭제 | ||
|
|
||
| 비어있는 스택에서 원소 추출 → stack underflow | ||
|
|
||
| 스택이 넘치는 경우 → stack overflow | ||
|
|
||
| ### 활용 예시 | ||
|
|
||
| - 웹 브라우저 뒤로가기 | ||
| - 역순 문자열 만들기 | ||
| - 실행 취소 | ||
| - 후위 표기법 계산 | ||
| - 수식의 괄호 검사 : 연산자 우선순위 표현을 위한 괄호 검사 |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // 문자열 my_string이 매개변수로 주어집니다. my_string을 거꾸로 뒤집은 문자열을 return하도록 solution 함수를 완성해주세요. | ||
| function solution(my_string) { | ||
| return [...my_string].reverse().join(''); | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // my_string은 "3 + 5"처럼 문자열로 된 수식입니다. | ||
| // 문자열 my_string이 매개변수로 주어질 때, | ||
| // 수식을 계산한 값을 return 하는 solution 함수를 완성해주세요. | ||
|
|
||
| function solution(my_string) { | ||
| const newArr = my_string.split(' ').join(''); | ||
| return eval(newArr); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문제를 잘이해하지못했었는데 풀이를 보고 잘이해하게되었습니다.