WIL(09.19~09.24)

전성영·2022년 9월 26일
0

WIL

목록 보기
16/22

09.26 - 1

프로그래머스 Level 2 프린터 문제를 풀었다.
예~~~전에 pair에 대해서 정리해놓았던 게 있기도 하고 우선순위 큐 또한 있어서 문제를 이해하는 데에는 크게 어려움은 없었지만 중간에 힌트를 얻긴했다..
블로그의 필요성을 다시 한번 느낄 수 있었따.

int solution(vector<int>priorities, int location) {
	int answer = 0, count = 0;

	for (int i = 0; i < priorities.size(); i++) {
		pq.push(priorities[i]);
		q.push(make_pair(i, priorities[i]));
	}

    while (!q.empty()) {
        int idx = q.front().first;
        int value = q.front().second;
        q.pop();

        if (pq.top() == value) {
            pq.pop();
            count++;

            if (idx == location) {
                answer = count;
                break;
            }
        }
		else
            q.push(make_pair(idx, value));
    }

	return answer;
}

09.26

@Query("select t from Todo t where t.id not in (:skip)")
List<Todo> findAllByTodoList(Pageable pageable, @Param("skip") Long skip);

not in 문법이 안 돼서 헤맸었다.
일단 처음엔 int로 받았었고, 다음엔 String .. 골고루 아주..
찾아본 결과 Long 타입으로 받았어야 했다.
끄읏!

profile
Slow and Steady

0개의 댓글