代码拉取完成,页面将自动刷新
<p>Given an array of functions <code>[f<span style="font-size: 10.8333px;">1</span>, f<sub>2</sub>, f<sub>3</sub>, ..., f<sub>n</sub>]</code>, return a new function <code>fn</code> that is the <strong>function composition</strong> of the array of functions.</p>
<p>The <strong>function composition</strong> of <code>[f(x), g(x), h(x)]</code> is <code>fn(x) = f(g(h(x)))</code>.</p>
<p>The <strong>function composition</strong> of an empty list of functions is the <strong>identity function</strong> <code>f(x) = x</code>.</p>
<p>You may assume each function in the array accepts one integer as input and returns one integer as output.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> functions = [x => x + 1, x => x * x, x => 2 * x], x = 4
<strong>Output:</strong> 65
<strong>Explanation:</strong>
Evaluating from right to left ...
Starting with x = 4.
2 * (4) = 8
(8) * (8) = 64
(64) + 1 = 65
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> functions = [x => 10 * x, x => 10 * x, x => 10 * x], x = 1
<strong>Output:</strong> 1000
<strong>Explanation:</strong>
Evaluating from right to left ...
10 * (1) = 10
10 * (10) = 100
10 * (100) = 1000
</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> functions = [], x = 42
<strong>Output:</strong> 42
<strong>Explanation:</strong>
The composition of zero functions is the identity function</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code><font face="monospace">-1000 <= x <= 1000</font></code></li>
<li><code><font face="monospace">0 <= functions.length <= 1000</font></code></li>
<li>all functions accept and return a single integer</li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。