Skip to content

Commit ef2b317

Browse files
add skeleton for 1237
1 parent 3bb4eca commit ef2b317

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Your ideas/fixes/algorithms are more than welcome!
2828
| # | Title | Solutions | Time | Space | Video | Difficulty | Tag
2929
|-----|----------------|---------------|---------------|---------------|--------|-------------|-------------
3030
|1252|[Cells with Odd Values in a Matrix](https://leetcode.com/problems/cells-with-odd-values-in-a-matrix/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1252.java) | O(m*n + k) | O(m*n) | |Easy||
31+
|1237|[Find Positive Integer Solution for a Given Equation](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1237.java) | O(?) | O(?) | |Easy||
3132
|1207|[Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1207.java) | O(n) | O(1) | |Easy||
3233
|1160|[Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1160.java) | O(n) | O(m) | |Easy||
3334
|1154|[Day of the Year](https://leetcode.com/problems/day-of-the-year/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1154.java) | O(1) | O(1) | |Easy||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.List;
4+
5+
/**
6+
* 1237. Find Positive Integer Solution for a Given Equation
7+
*
8+
* Given a function f(x, y) and a value z, return all positive integer pairs x and y where f(x,y) == z.
9+
* The function is constantly increasing, i.e.:
10+
*
11+
* f(x, y) < f(x + 1, y)
12+
* f(x, y) < f(x, y + 1)
13+
* The function interface is defined like this:
14+
*
15+
* interface CustomFunction {
16+
* public:
17+
* // Returns positive integer f(x, y) for any given positive integer x and y.
18+
* int f(int x, int y);
19+
* };
20+
* For custom testing purposes you're given an integer function_id and a target z as input,
21+
* where function_id represent one function from an secret internal list, on the examples you'll know only two functions from the list.
22+
* You may return the solutions in any order.
23+
*
24+
* Example 1:
25+
* Input: function_id = 1, z = 5
26+
* Output: [[1,4],[2,3],[3,2],[4,1]]
27+
* Explanation: function_id = 1 means that f(x, y) = x + y
28+
*
29+
* Example 2:
30+
* Input: function_id = 2, z = 5
31+
* Output: [[1,5],[5,1]]
32+
* Explanation: function_id = 2 means that f(x, y) = x * y
33+
*
34+
* Constraints:
35+
* 1 <= function_id <= 9
36+
* 1 <= z <= 100
37+
* It's guaranteed that the solutions of f(x, y) == z will be on the range 1 <= x, y <= 1000
38+
* It's also guaranteed that f(x, y) will fit in 32 bit signed integer if 1 <= x, y <= 1000
39+
*/
40+
public class _1237 {
41+
42+
// This is the custom function interface.
43+
// You should not implement it, or speculate about its implementation
44+
interface CustomFunction {
45+
// Returns f(x, y) for any given positive integers x and y.
46+
// Note that f(x, y) is increasing with respect to both x and y.
47+
// i.e. f(x, y) < f(x + 1, y), f(x, y) < f(x, y + 1)
48+
public int f(int x, int y);
49+
}
50+
51+
public static class Solution1 {
52+
public List<List<Integer>> findSolution(CustomFunction customfunction, int z) {
53+
return null;
54+
}
55+
}
56+
57+
}

0 commit comments

Comments
 (0)