How to use Array.reduceRight to solve LeetCode 2629. Function Composition problem?

Hoang Dinh
Level Up Coding
Published in
3 min readMay 7, 2023

--

Photo by Max Chen on Unsplash

2629. Function Composition

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…

--

--