본문 바로가기
반응형

SWE327

QGraphicsView QGraphicsItem 이란? 사용시 주의사항 1. QGraphicsItem 을 상속받은 위젯을 만들 때는 boundingRect() , paint() 함수를 구현해줘야 한다. boundingRect와 Pain 함수는 둘 다 순수 가상함수로, 구현해주지 않으면 빌드 에러가 나온다. 2. QGraphicView와 QGraphicsItem은 mouseEvent를 받을 수 없다. QGraphicsScene---Event를 전달 받을 수 있다. void mouseMoveEvent(QMouseEvent* event) void hoverEnterEvent(QGraphicsSceneHoverEvent *event) 3. QgraphicsItem에서 마우스 이벤트 받으려면 event flag 설정해줘야 한다. default는 false로 마우스 이.. 2022. 3. 17.
[Leetcode][python] 11. Container With Most Water problem: https://leetcode.com/problems/container-with-most-water/ code: brute-force time limit exceeded class Solution: def maxArea(self, height: List[int]) -> int: left = 0 right = len(height)-1 result = 0 while(left int: left = 0 right = len(height)-1 maxWater = 0 while left result maxWater = max(m.. 2022. 3. 10.
[Leetcode][python3] 112. Path Sum problem: https://leetcode.com/problems/path-sum/ code : dfs recursive # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def hasPathSum(self, root: Optional[TreeNode], targetSum: int) -> bool: # recursive def _dfs(cur, curSum): # exit condition if cur == None : return .. 2022. 3. 10.
[Leetcode][python3] 442. Find All Duplicates in an Array problem: https://leetcode.com/problems/find-all-duplicates-in-an-array/ code: class Solution: def findDuplicates(self, nums: List[int]) -> List[int]: hashmap = dict() result = [] for num in nums: # n times if num in hashmap : #O(1) result.append(num) else: hashmap[num]=True return result # time complexity # O(n) # space complextiy # O(n) code: class Solution: def findDuplicates(self, nums: List[.. 2022. 3. 10.
반응형