-
Notifications
You must be signed in to change notification settings - Fork 0
/
FIND +ve INTEGER SULUTION OF A GIVEN EQUATION .cpp
52 lines (47 loc) · 1.46 KB
/
FIND +ve INTEGER SULUTION OF A GIVEN EQUATION .cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// ** // This i/s the custom function interface.
// * // You should not implement it, or speculate about its implementation
// *class CustomFunction
// {
// *public : * // 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)
// *int
// f(int x, int y);
// *
// };
// * /
/* #include<bits/stdc++.h>
using namespace std;
class Solution
{
public:
vector<vector<int>> findSolution(CustomFunction &customfunction, int z)
{
vector<vector<int>> res;
for (int x = 1; x <= z; x++)
{
int s = 1;
int e = z;
while (s <= e)
{
int mid = s + (e - s) / 2;
if (customfunction.f(x, mid) == z)
{
vector<int> t = {x, mid};
res.push_back(t);
e = mid - 1;
}
else if (customfunction.f(x, mid) > z)
{
e = mid - 1;
}
else
{
s = mid + 1;
}
}
}
return res;
}
}; */
// LEETCODE PROBLEM - 1237