CodingTest/프로그래머스/2/87390. n^2 배열 자르기 at main · kwon1232/CodingTest
This is an auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - kwon1232/CodingTest
github.com

#include <string>
#include <vector>
using namespace std;
vector<int> solution(int n, long long left, long long right) {
vector<int> answer;
int row = left / n;
int col = left % n;
int count = right - left + 1;
for (int i = 1; i <= count; i++)
{
int num = max(row + 1, col + 1);
answer.push_back(num);
col++;
if(col == n)
{
row++;
col = 0;
}
}
return answer;
}
https://school.programmers.co.kr/learn/courses/30/lessons/87390
'콘솔창 & 윈도우창 > 코딩 테스트' 카테고리의 다른 글
프로그래머스 LV.2 점프와 순간이동 (0) | 2025.04.06 |
---|---|
백준 골드4 카드 정렬하기 (0) | 2025.04.06 |
프로그래머스 LV.2 연속 부분 수열의 합의 개수 (0) | 2025.03.31 |
프로그래머스 LV.3 야근 지수 (0) | 2025.03.31 |
프로그래머스 LV.2 롤케이크 자르기 (0) | 2025.03.30 |