Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Python
- 이코테
- json-server
- 프로그래머스
- useDispatch
- 리액트
- createSlice
- programmers
- java
- 코딩테스트합격자되기
- 항해99
- react
- Get
- sw expert academy
- 자바
- JavaScript
- 항해플러스
- react-router
- C++
- axios
- react-redux
- redux-saga
- 매일메일
- maeil-mail
- 알고리즘
- redux
- 테코테코
- SW
- Algorithm
- redux-toolkit
Archives
- Today
- Total
Binary Journey
[프로그래머스] n^2 배열 자르기 본문
반응형
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges
월간코드챌린지 때 효율성에서 막혀서 결국 못 풀었는데 풀이 보고 너무나도 간단해서 놀랐다.
1차원 배열을 n 으로 나눈 몫, 나머지에서 max 값만 구하면 되다니..
** python
def solution(n, left, right):
answer = []
for i in range(left, right + 1):
answer.append(max(divmod(i, n)) + 1)
return answer
참고: https://sangsangss.tistory.com/197
[프로그래머스] n^2 배열 자르기
https://programmers.co.kr/learn/courses/30/lessons/87390 코딩테스트 연습 - n^2 배열 자르기 정수 n, left, right가 주어집니다. 다음 과정을 거쳐서 1차원 배열을 만들고자 합니다. n행 n열 크기의 비어있는..
sangsangss.tistory.com
반응형
'프로그래머스 > level 2' 카테고리의 다른 글
[프로그래머스] 괄호 회전하기 (0) | 2022.01.25 |
---|---|
[프로그래머스] 스킬트리 (1) | 2022.01.18 |
[프로그래머스] 방문 길이 (0) | 2022.01.04 |
[프로그래머스] 방금그곡 (0) | 2022.01.04 |
[프로그래머스] 파일명 정렬 (0) | 2021.12.28 |