leetcode 1237

 1 class Solution:
 2     def findSolution(self, customfunction: 'CustomFunction', z: int) -> List[List[int]]:
 3         x,y = 1,1001
 4         res = []
 5         while x < 1001 and y > 0:
 6             v = customfunction.f(x,y)
 7             if v < z:
 8                 x += 1
 9             elif v > z:
10                 y -= 1
11             else:
12                 res.append([x,y])
13                 x += 1
14                 y -= 1
15         return res

我没太理解这题是要干什么,参考https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation/discuss/414158/JavaPython-3-3-methods%3A-time-O(x-%2B-y)-O(xlogy)-and-O(x-%2B-logy)-w-analysis.

你可能感兴趣的:(leetcode 1237)