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
- 자바
- database
- Data Structure
- Binary Tree
- Binary Search
- sorting
- bit manipulation
- Matrix
- geometry
- 구현
- java
- Counting
- SQL
- hash table
- Tree
- dynamic programming
- Math
- two pointers
- 코딩테스트
- implement
- array
- Number Theory
- Class
- Stack
- greedy
- 코테
- Method
- 파이썬
- string
- simulation
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 정사각형으로 만들기 본문
1. Input, Output, Example
- arr의 행의 수가 더 많다면 열의 수가 행의 수와 같아지도록 각 행의 끝에 0을 추가하고, 열의 수가 더 많다면 행의 수가 열의 수와 같아지도록 각 열의 끝에 0을 추가한 이차원 배열을 반환
2. Constraint
1) 1 ≤ arr의 길이 ≤ 100
2) 1 ≤ arr의 원소의 길이 ≤ 100
3) arr의 모든 원소의 길이는 같다.
4) 1 ≤ arr의 원소의 원소 ≤ 1,000
3. Code
1) 첫 코드(2023/05/01)
class Solution {
public int[][] solution(int[][] arr) {
int r = arr.length, c = arr[0].length;
int n = Math.max(r,c);
int[][] answer = new int[n][n];
for(int i=0 ; i<arr.length ; i++)
System.arraycopy(arr[i], 0, answer[i], 0, c);
return answer;
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2325. Decode the Message (0) | 2023.05.02 |
---|---|
[프로그래머스/Lv.0] 이차원 배열 대각선 순회하기 (0) | 2023.05.01 |
[프로그래머스/Lv.0] 조건에 맞게 수열 변환하기 2 (0) | 2023.05.01 |
[프로그래머스/Lv.0] 2의 영역 (0) | 2023.05.01 |
[프로그래머스/Lv.0] 배열의 길이를 2의 거듭제곱으로 만들기 (0) | 2023.05.01 |