https://school.programmers.co.kr/learn/courses/30/lessons/87390
이건 무슨 알고리즘이지... 창의력..?
#include <string>
#include <vector>
using namespace std;
vector<int> solution(int n, long long left, long long right) {
vector<int> answer;
while (left <= right)
{
int x = left / n, y = left % n;
if (x >= y)
answer.push_back(x + 1);
else
answer.push_back(y + 1); // index니까 1 더해줌
left++;
}
return answer;
}
// 만약 arr[x][y] 에서 x > y 이면 x이고 x < y 이면 y다
// arr[i / n][i % n]
'<algorithm> > 프로그래머스' 카테고리의 다른 글
프로그래머스 행렬의 곱셈 c++ (0) | 2023.06.06 |
---|---|
프로그래머스 캐시 c++ (0) | 2023.06.05 |
프로그래머스 괄호 회전하기 c++ (0) | 2023.06.01 |
프로그래머스 연속 부분 수열 합의 개수 c++ (0) | 2023.05.29 |
프로그래머스 귤 고르기 c++ (0) | 2023.05.29 |