Find Positive Integer Solution for a Given Equation LeetCode solution in JavaScript
1/**2* // This is the CustomFunction's API interface.3* // You should not implement it, or speculate about its implementation4* function CustomFunction() {5* @param {integer, integer} x, y6* @return {integer}7* this.f = function(x, y) {8* ...9* };10* };11*/1213/**14* @param {CustomFunction} customfunction15* @param {integer} z16* @return {integer[][]}17*/18var findSolution = function (customfunction, z) {19var ans = [];20var x = 1,21y = 1000;22while (x <= 1000 && y > 0) {23if (customfunction.f(x, y) > z) {24y--;25} else if (customfunction.f(x, y) < z) {26x++;27} else {28ans.push([x, y]);29x++;30y--;31}32}33return ans;34};