Practice Allow One Function Call
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Easy#2666
LeetCode ProblemAllow One Function Call
Problem Statement
Given a function fn, return a new function that is identical to the original function except that it ensures fn is called at most once.
Source: Allow One Function Call on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
fn = (a,b,c) => (a + b + c), calls = [[1,2,3],[2,3,6]]
Output
[{"calls":1,"value":6}]# Example 2
Input
fn = (a,b,c) => (a * b * c), calls = [[5,7,4],[2,3,6],[4,6,8]]
Output
[{"calls":1,"value":140}]Constraints
calls is a valid JSON array
1 <= calls.length <= 10
1 <= calls[i].length <= 100
2 <= JSON.stringify(calls).length <= 1000
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.