본문 바로가기

분류 전체보기

(62)
[Leetcode 2257번 문제] 2257. Count Unguarded Cells in the Grid 문제 상황You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [rowi, coli] and walls[j] = [rowj, colj] represent the positions of the ith guard and jth wall respectively.A guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless obstructed b..
[Leetcode 2516번 문제] 2516. Take K of Each Character From Left and Right 문제 상황You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s.Return the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character.characters a, b, c로 이루어져있고, 음이아닌 정수 k가 있다. 매..
[Leetcode 862번 문제] 862. Shortest Subarray with Sum at Least K 문제 상황Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1.A subarray is a contiguous part of an array.nums와 k가 주어진다. 가장 작은 길이의 비어있지 않은 subarray를 내라. 그 subarray는 합이 k다. 없으면 -1을 리턴해라.입력1 105 1 출력과정순서가 유지되는 subarray를 리턴해야하고 input값은 음수를 끼고있는 배열,음수는 정렬의 적이다. 원래같으면 그냥 바로 누적값으로 정렬할 수 ..
[Leetcode 3254번 문제] 3254. Find the Power of K-Size Subarrays I. 문제 상황You are given an array of integers nums of length n and a positive integer k.The power of an array is defined as:Its maximum element if all of its elements are consecutive and sorted in ascending order.1 otherwise.You need to find the power of all subarrays of nums of size k.Return an integer array results of size n - k + 1, where results[i] is the power of nums[i..(i + k - 1)].i 번째부터 i + k..
[백준 14451번 문제] 안대 낀 스피드러너 문제 상황문제가 되는 파트의 난이도 자체가 높은 것은 아니다. 장애물이 격자 형태로 놓여 있고, 왼쪽 아래에서 출발해서 오른쪽 위로 가면 되는 간단한 파트다. 심지어 이 장애물도 게임을 킬 때마다 랜덤으로 배치되는 게 아니라 위치가 고정되어 있다. 문제는 처음에 어느 방향으로 서 있는지가 랜덤이라는 것이다. 안대를 꼈으니 방향을 알 방법이 없다.N×N 격자가 있고, 2≤N≤20이다. 몇몇 칸에는 거대한 장애물이 있어서 지나갈 수 없고, 나머지는 비어 있어서 자유롭게 지나갈 수 있다. 격자 외부도 벽으로 둘러싸여 있어서 밖으로 나갈 수 없다. 주인공은 처음에 왼쪽 아래에 있고, 어느 방향으로 서 있는지는 모르지만 위와 오른쪽 중 하나인 것은 확실하다. 주인공은 매초 "전진", "좌회전", "우회전" 중 하..
[C++] WCHAR, TCHAR, cstring 정리 이런 것에 대한 정보를 담고 있다WCHAR과 TCHAR이 무엇인지가변길이 문자열 vs 고정 길이 문자열cstring string의 차이WCHAR 문자열 만드는법.이런 것에 대한 정보는 담겨있지 않다1. WCHAR과 TCHAR이 무엇인지우선 WCHAR은 wind-character 이라고 하는 문자이다. 일반적으로 문자는 1바이트라고 배운다. 0부터 127까지의 비트로 문자를 구분해놓은 아스키(ASCII)가 대표적인 1바이트 문자이다. 그럼 당연히 wide string이라는건 2바이트 이상의 문자열을 의미하겠다 라고 생각할 수 있다.그렇다면 TCHAR은 무엇일까 TCHAR은 1바이트 문자 CHAR과 2바이트 문자 WCHAR을 통일해서 쓰기 위해 만들어졌다. 유니코드를 사용하는 경우 TCHAR은 2바이트 문자..
[Leetcode 2955번 문제] 2955. Number of Same-End Substrings 문제 상황You are given a 0-indexed string s, and a 2D array of integers queries, where queries[i] = [li, ri] indicates a substring of s starting from the index li and ending at the index ri (both inclusive), i.e. s[li..ri].각각의 쿼리가 subarrayReturn an array ans where ans[i] is the number of same-end substrings of queries[i].same-end?A 0-indexed string t of length n is called same-end if it has the same..
[Leetcode 2064번 문제] 2064. Minimized Maximum of Products Distributed to Any Store 문제 상황You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the ith product type.You need to distribute all products to the retail stores following these rules:A store can only be given at most one product type but can..