본문 바로가기

전체 글

[Leetcode/파이썬] 80. Remove Duplicates from Sorted Array II Remove Duplicates from Sorted Array IIGiven an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the elements should be kept the same.Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. .. 더보기
[Leetcode/파이썬] 36. Valid Sudoku Valid SudokuDetermine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition.Each column must contain the digits 1-9 without repetition.Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without repetition.Note:A Sudoku board (partially filled) could be valid but i.. 더보기
[Leetcode/파이썬] 71. Simplify Path Simplify PathYou are given an absolute path for a Unix-style file system, which always begins with a slash '/'. Your task is to transform this absolute path into its simplified canonical path.The rules of a Unix-style file system are as follows:A single period '.' represents the current directory.A double period '..' represents the previous/parent directory.Multiple consecutive slashes such as '.. 더보기
[Leetcode/파이썬] 238. Product of Array Except Self Product of Array Except SelfGiven an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.You must write an algorithm that runs in O(n) time and without using the division operation. Example 1:Input: nums = [1,2,3,4]Output: [24,12,8,6]E.. 더보기
[Leetcode/파이썬] 63. Unique Paths II Unique Paths IIYou are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.An obstacle and space are marked as 1 or 0 respectively in grid. A path that the robot takes cannot include any squar.. 더보기
[Leetcode/파이썬] 73. Set Matrix Zeroes Set Matrix ZeroesGiven an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.You must do it in place. Example 1:Input: matrix = [[1,1,1],[1,0,1],[1,1,1]]Output: [[1,0,1],[0,0,0],[1,0,1]]Example 2:Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]Output: [[0,0,0,0],[0,4,5,0],[0,3,1,0]] Constraints:m == matrix.lengthn == matrix[0].length1 -231 31 - 1 Follow up:A str.. 더보기
[백준/파이썬] 17141. 연구소2 [Gold IV] 연구소 2 - 17141문제 링크성능 요약메모리: 114932 KB, 시간: 196 ms분류그래프 이론, 브루트포스 알고리즘, 그래프 탐색, 너비 우선 탐색, 격자 그래프제출 일자2025년 10월 1일 16:19:16문제 설명인체에 치명적인 바이러스를 연구하던 연구소에 승원이가 침입했고, 바이러스를 유출하려고 한다. 승원이는 연구소의 특정 위치에 바이러스 M개를 놓을 것이고, 승원이의 신호와 동시에 바이러스는 퍼지게 된다.연구소는 크기가 N×N인 정사각형으로 나타낼 수 있으며, 정사각형은 1×1 크기의 정사각형으로 나누어져 있다. 연구소는 빈 칸, 벽으로 이루어져 있으며, 벽은 칸 하나를 가득 차지한다.일부 빈 칸은 바이러스를 놓을 수 있는 칸이다. 바이러스는 상하좌우로 인접한 모든 빈.. 더보기
[백준/파이썬] 17244. 아맞다우산 [Gold II] 아맞다우산 - 17244문제 링크성능 요약메모리: 115380 KB, 시간: 124 ms분류그래프 이론, 그래프 탐색, 너비 우선 탐색, 비트마스킹, 격자 그래프제출 일자2025년 11월 24일 20:21:14문제 설명경재씨는 저녁 약속을 가기 전 챙기지 않은 물건들이 있는 지 확인하고 있다. 필요한 물건은 전부 챙긴 것 같았고 외출 후 돌아오는 길에 경재씨는 외쳤다."아 맞다 우산!!!"경재 씨는 매번 외출하고 나서야 어떤 물건을 집에 놓고 왔다는 것을 떠올릴 때마다 자책감에 시달리는 것이 너무 싫었다.외출이 잦은 경재 씨는 반복되는 일을 근절하기 위해 꼭 챙겨야 할 물건들을 정리해보았다. 하지만 지갑, 스마트폰, 우산, 차 키, 이어폰, 시계, 보조 배터리 등 종류와 개수가 너무 많.. 더보기