Level 0. 가까운 1 찾기
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> arr, int idx)
{
auto result = find(next(arr.begin(), idx), arr.end(), 1);
return (result == arr.end()) ? -1 : result - arr.begin();
}
'자료구조 & 알고리즘 > 프로그래머스' 카테고리의 다른 글
Level 0. 특별한 이차원 배열 2 (0) | 2023.06.25 |
---|---|
Level 0. 수 조작하기 2 (0) | 2023.06.24 |
Level 2. 2 x n 타일링 (0) | 2023.06.22 |
Level 0. 등차수열의 특정한 항만 더하기 (0) | 2023.06.21 |
Level 2. 두 큐 합 같게 만들기 (0) | 2023.06.20 |