Practice Function Composition
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Function Composition
Problem Statement
Given an array of functions [f1, f2, f3, ..., fn], return a new function fn that is the function composition of the array of functions. The function composition of [f(x), g(x), h(x)] is fn(x) = f(g(h(x))). The function composition of an empty list of functions is the identity function f(x) = x. You may assume each function in the array accepts one integer as input and returns one integer as output.
Source: Function Composition on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
functions = [x => x + 1, x => x * x, x => 2 * x], x = 4
65
# Example 2
functions = [x => 10 * x, x => 10 * x, x => 10 * x], x = 1
1000
# Example 3
functions = [], x = 42
42
Constraints
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.