목록분류 전체보기 (594)
넘치게 채우기
https://leetcode.com/problems/find-the-safest-path-in-a-grid/description/leetcode - Find the Safest Path in a Grid문제 유형 : bfs, 우선순위 큐, 다익스트라, 최단거리문제 난이도 : Medium 문제You are given a 0-indexed 2D matrix grid of size n x n, where (r, c) represents:A cell containing a thief if grid[r][c] = 1An empty cell if grid[r][c] = 0You are initially positioned at cell (0, 0). In one move, you can move to any ad..
https://leetcode.com/problems/path-with-maximum-gold/description/leetcode - Path with Maximum Gold문제 유형 : dfs, 백트래킹, 행렬, 재귀문제 난이도 : Medium 문제In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.Return the maximum amount of gold you can collect under the conditions:Every time you are located in a cell you will coll..
https://leetcode.com/problems/score-after-flipping-matrix/description/leetcode - Score After Flipping Matrix문제 유형 : 행렬, 비트마스킹, 그리디문제 난이도 : Medium 문제You are given an m x n binary matrix grid.A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's).Every row of the matrix is interpreted as a binary number, and t..
https://leetcode.com/problems/largest-local-values-in-a-matrix/description/leetcode - Largest Local Values in a Matrix문제 유형 : 행렬, 구현문제 난이도 : Easy 문제You are given an n x n integer matrix grid.Generate an integer matrix maxLocal of size (n - 2) x (n - 2) such that:maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1.In other words, we ..
https://leetcode.com/problems/minimum-cost-to-hire-k-workers/description/leetcode - Minimum Cost to Hire K Workers문제 유형 : 우선순위 큐, 정렬문제 난이도 : Hard 문제There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker.We want to hire exactly k workers to form a paid group. To hire a ..
https://leetcode.com/problems/k-th-smallest-prime-fraction/description/leetcode - K-th Smallest Prime Fraction문제 유형 : 이진탐색, 브루트 포스문제 난이도 : Medium 문제You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k.For every i and j where 0 arr[i] / arr[j].Return the kth smallest fraction considered. Return your ans..
int INT_MAX = (unsigned int) -1 >> 1; 본론부터 말하자면, 위와 같다. 1을 4비트 + 부호비트로 표현하면, 00001이다.-1은? 2의 보수를 취하여 11111이다. unsigned로 형변환하면서, MSB인 부호 비트도 수 표현 비트로 바뀌면서, -1은 1이 32개 나열된 비트로 바뀐다.이 값에서 다시 오른쪽 시프트 연산을 하여 최하위 비트를 자르면? 1이 31개 나열된 채로, 2^31-1로 된다. 즉, INT_MAX의 값이 된다.
https://leetcode.com/problems/maximize-happiness-of-selected-children/description/leetcode - Maximize Happiness of Selected Children문제 유형 : 정렬 / 그리디문제 난이도 : Medium 문제You are given an array happiness of length n, and a positive integer k.There are n children standing in a queue, where the ith child has happiness value happiness[i]. You want to select k children from these n children in k turns.In..
https://leetcode.com/problems/relative-ranks/description/leetcode - Relative Ranks문제 유형 : 우선순위 큐문제 난이도 : Easy 문제You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique.The athletes are placed based on their scores, where the 1st place athlete has the highest score, the 2nd place athlete has the 2n..
https://leetcode.com/problems/double-a-number-represented-as-a-linked-list/description/leetcode - Double a Number Represented as a Linked List문제 유형 : 연결 리스트, 재귀문제 난이도 : Medium 문제You are given the head of a non-empty linked list representing a non-negative integer without leading zeroes.Return the head of the linked list after doubling it. 연결리스트의 Head를 받습니다.이 연결리스트는 양의 정수를 의미합니다.두 배 하시오. 풀이재귀적으로 ..