목록알고리즘 문제풀이 (31)
취미가 좋다
https://leetcode.com/problems/next-permutation/ Next Permutation - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution class Solution: def nextPermutation(self, nums): temp = [] for idx in range(len(nums)-1, 0, -1): if nums[idx] nums[idx-1]: temp[i], nums[idx-1] = nums[idx-1],..
https://leetcode.com/problems/search-a-2d-matrix-ii/ Search a 2D Matrix II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution class Solution: def searchMatrix(self, matrix, target): row, col = 0, len(matrix[0])-1 while row = 0: if matrix[row][col] < t..
https://leetcode.com/problems/sliding-window-maximum/submissions/ Sliding Window Maximum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution import heapq from collections import defaultdict class Solution: def maxSlidingWindow(self, nums, k): ans = [max(nums[:k])] pq = [] ou..
https://leetcode.com/problems/product-of-array-except-self/ Product of Array Except Self - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution class Solution: def productExceptSelf(self, nums): if nums.count(0) > 1: return [0]*len(nums) idx = -1 total = 1 for i, n in enumerate..
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ Lowest Common Ancestor of a Binary Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution class Solution: def __init__(self): self.ans = None def lowestCommonAncestor(self, root, p, q) : ans = None def ..
https://www.acmicpc.net/problem/2636 2636번: 치즈 아래 과 같이 정사각형 칸들로 이루어진 사각형 모양의 판이 있고, 그 위에 얇은 치즈(회색으로 표시된 부분)가 놓여 있다. 판의 가장자리(에서 네모 칸에 X친 부분)에는 치즈가 놓 www.acmicpc.net Solution import sys input = sys.stdin.readline from collections import deque def melt(): num = 0 while(ready): i, j = ready.pop() cheese[i][j] = 0 num += 1 return num def chk(): while(q): i, j = q.pop() if cheese[i][j] == 1: ready.app..