We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent db79189 commit 78d7799Copy full SHA for 78d7799
src/main/java/com/fishercoder/solutions/_1237.java
@@ -96,9 +96,25 @@ public static class Solution3 {
96
* binary search
97
*
98
* Time: O(xlogy)
99
- * Space: O(1)*/
+ * Space: O(1)
100
+ * */
101
public List<List<Integer>> findSolution(CustomFunction customfunction, int z) {
102
List<List<Integer>> result = new ArrayList<>();
103
+ for (int x = 1; x <= 1000; x++) {
104
+ int left = 1;
105
+ int right = 1001;
106
+ while (left < right) {
107
+ int y = (left + right) / 2;
108
+ if (customfunction.f(x, y) < z) {
109
+ left = y + 1;
110
+ } else {
111
+ right = y;
112
+ }
113
114
+ if (customfunction.f(x, left) == z) {
115
+ result.add(Arrays.asList(x, left));
116
117
118
return result;
119
}
120
0 commit comments