Untitled
unknown
plain_text
4 months ago
557 B
4
Indexable
this part can we rite as solve(idx,diff) { int a = INT_MIN; // take if(idx+1<arr.length && nums[idx+1] - nums[idx] == diff) { a = 1 + solve(idx+1,diff); } a = MAX(a,solve(idx,diff)) return a; } ChatGPT said: Your idea is close, but there are some issues in the logic that need to be fixed: Incorrect recursive call in a = MAX(a, solve(idx, diff)) You are calling solve(idx, diff) instead of solve(idx + 1, diff), which means you're not moving forward. This would cause an infinite recursion (or incorrect results).
Editor is loading...
Leave a Comment