diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/835. Image Overlap.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/835. Image Overlap.py" new file mode 100644 index 00000000..ee74c4bd --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/835. Image Overlap.py" @@ -0,0 +1,42 @@ +# + +''' +1. 아이디어 : +한칸씩 옮긴다음 계산한다. + +2. 시간복잡도 : + O(n**4) + +3. 자료구조/알고리즘 : +- + +''' +class Solution: + def largestOverlap(self, img1: list[list[int]], img2: list[list[int]]) -> int: + n = len(img1) + + def get_count(offset_x, offset_y): + count = 0 + + for x in range(n): + for y in range(n): + mx = x + offset_x + my = y + offset_y + if 0<=mx bool: + count = {5:0, 10:0, 20:0} #5, 10, 20 + + def is_possible(payment): + if payment == 20: + if count[10] >= 1 and count[5] >= 1: + count[10] -= 1 + count[5] -= 1 + count[20] += 1 + return True + elif count[10] == 0 and count[5] >= 3: + count[5] -= 3 + count[20] += 1 + return True + elif payment == 10: + if count[5] >= 1: + count[5] -= 1 + count[10] += 1 + return True + elif payment == 5: + count[5] += 1 + return True + + return False + + for b in bills: + if not is_possible(b): + return False + return True +