문제 링크: https://neetcode.io/problems/meeting-schedule NeetCode neetcode.io [내 풀이]"""Definition of Interval:class Interval(object): def __init__(self, start, end): self.start = start self.end = end"""class Solution: def canAttendMeetings(self, intervals: List[Interval]) -> bool: intervals.sort(key=lambda x: x.start) for i in range(len(intervals) - 1): ..
NeetCode
문제 링크: https://neetcode.io/problems/buy-and-sell-crypto NeetCode neetcode.io 투 포인터/슬라이딩 윈도우 [내 풀이]class Solution: def maxProfit(self, prices: List[int]) -> int: maxProfit = 0 for i in range(len(prices)-1): for j in range(i, len(prices)): profit = prices[j] - prices[i] if profit > maxProfit: maxProfit = profit ret..
문제 링크: https://neetcode.io/problems/min-cost-climbing-stairs NeetCode neetcode.io 예전에 알고리즘 감을 살릴겸, 순차적으로 구하는 방법, 역순으로 구하는 방법 두 방법 모두를 사용해서 풀어보았다.점점 이제 이지 난이도에서 벗어나야할텐데... 준비중이다! [내 코드 1: 순차적 풀이]class Solution: def minCostClimbingStairs(self, cost: List[int]) -> int: n = len(cost) result = [0 for i in range(len(cost))] # cost.length >= 2 result[0], result[1] = cost..
문제: https://neetcode.io/problems/is-palindrome NeetCode neetcode.io [내 풀이]class Solution: def isPalindrome(self, s: str) -> bool: s = ''.join(x for x in s if x.isalnum()).lower() for i in range(len(s)//2): l = 0 + i r = len(s) - 1 - i if s[l] == s[r]: pass else: return False return True python은 코테 언..