목록lev3 (13)
취미가 좋다
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/consecutive-numbers/ Consecutive Numbers - 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 select distinct l.Num as ConsecutiveNums from Logs l left join Logs r on l.Num = r.Num and r.Id < l.Id and l.Id -r.Id
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://leetcode.com/problems/maximal-square/ Maximal Square - 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 maximalSquare(self, matrix): ROW, COL = len(matrix), len(matrix[0]) ans = 0 for i in range(COL): matrix[0][i] = 1 if matrix[0][i]=='1' else 0 ..
https://www.acmicpc.net/problem/22868 22868번: 산책 (small) 첫 번째 줄에는 정점의 개수 $N$과 두 정점 사이를 잇는 도로의 개수 $M$이 공백으로 구분되어 주어진다. 두 번째 줄부터 $M + 1$ 번째 줄까지 정점 $A, B$가 공백으로 구분되어 주어진다. 정점 $A$와 www.acmicpc.net Solution from collections import defaultdict from queue import Queue import sys input = sys.stdin.readline n, m = map(int, input().split()) graph = defaultdict(list) for _ in range(m): a, b = map(int, inpu..