From 694fa52a38cfb794e162d8af14b007e453666fb3 Mon Sep 17 00:00:00 2001 From: Kang-bh Date: Tue, 1 Apr 2025 10:30:33 +0900 Subject: [PATCH] [4/1] --- .../Q2996.py" | 19 ++++++++++++++ .../Q1237.py" | 26 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 "leetcode2/1easy/\352\260\225\353\263\221\355\230\270/Q2996.py" create mode 100644 "leetcode2/2medium/\352\260\225\353\263\221\355\230\270/Q1237.py" diff --git "a/leetcode2/1easy/\352\260\225\353\263\221\355\230\270/Q2996.py" "b/leetcode2/1easy/\352\260\225\353\263\221\355\230\270/Q2996.py" new file mode 100644 index 00000000..a583021d --- /dev/null +++ "b/leetcode2/1easy/\352\260\225\353\263\221\355\230\270/Q2996.py" @@ -0,0 +1,19 @@ +class Solution: + def missingInteger(self, nums: list[int]) -> int: + + prefix_sum = nums[0] + + for i in range(1, len(nums)): + if nums[i] == nums[i-1] + 1: + prefix_sum += nums[i] + continue + else: + break + + while True: + if not prefix_sum in nums: + return prefix_sum + else: + prefix_sum += 1 + + return prefix_sum \ No newline at end of file diff --git "a/leetcode2/2medium/\352\260\225\353\263\221\355\230\270/Q1237.py" "b/leetcode2/2medium/\352\260\225\353\263\221\355\230\270/Q1237.py" new file mode 100644 index 00000000..2ef5f736 --- /dev/null +++ "b/leetcode2/2medium/\352\260\225\353\263\221\355\230\270/Q1237.py" @@ -0,0 +1,26 @@ +""" + This is the custom function interface. + You should not implement it, or speculate about its implementation + class CustomFunction: + # Returns f(x, y) for any given positive integers x and y. + # Note that f(x, y) is increasing with respect to both x and y. + # i.e. f(x, y) < f(x + 1, y), f(x, y) < f(x, y + 1) + def f(self, x, y): + +""" +# class CustomFunction: +# # Returns f(x, y) for any given positive integers x and y. +# # Note that f(x, y) is increasing with respect to both x and y. +# # i.e. f(x, y) < f(x + 1, y), f(x, y) < f(x, y + 1) +# def f(self, x, y): + +class Solution: + def findSolution(self, customfunction: 'CustomFunction', z: int) -> list[list[int]]: + result = [] + + for x in range(1, 1001): + for y in range(1, 1001): + if customfunction(x, y) == z: + result.append([x, y]) + + return result