|
| 1 | +# 672. Bulb Switcher II |
| 2 | + |
| 3 | +<p>There is a room with <code>n</code> bulbs labeled from <code>1</code> to <code>n</code> that all are turned on initially, and <strong>four buttons</strong> on the wall. Each of the four buttons has a different functionality where:</p> |
| 4 | + |
| 5 | +<ul> |
| 6 | + <li><strong>Button 1:</strong> Flips the status of all the bulbs.</li> |
| 7 | + <li><strong>Button 2:</strong> Flips the status of all the bulbs with even labels (i.e., <code>2, 4, ...</code>).</li> |
| 8 | + <li><strong>Button 3:</strong> Flips the status of all the bulbs with odd labels (i.e., <code>1, 3, ...</code>).</li> |
| 9 | + <li><strong>Button 4:</strong> Flips the status of all the bulbs with a label <code>j = 3k + 1</code> where <code>k = 0, 1, 2, ...</code> (i.e., <code>1, 4, 7, 10, ...</code>).</li> |
| 10 | +</ul> |
| 11 | + |
| 12 | +<p>You must make <strong>exactly</strong> <code>presses</code> button presses in total. For each press, you may pick <strong>any</strong> of the four buttons to press.</p> |
| 13 | + |
| 14 | +<p>Given the two integers <code>n</code> and <code>presses</code>, return <em>the number of <strong>different possible statuses</strong> after performing all </em><code>presses</code><em> button presses</em>.</p> |
| 15 | + |
| 16 | +<p> </p> |
| 17 | +<p><strong class="example">Example 1:</strong></p> |
| 18 | + |
| 19 | +<pre> |
| 20 | +<strong>Input:</strong> n = 1, presses = 1 |
| 21 | +<strong>Output:</strong> 2 |
| 22 | +<strong>Explanation:</strong> Status can be: |
| 23 | +- [off] by pressing button 1 |
| 24 | +- [on] by pressing button 2 |
| 25 | +</pre> |
| 26 | + |
| 27 | +<p><strong class="example">Example 2:</strong></p> |
| 28 | + |
| 29 | +<pre> |
| 30 | +<strong>Input:</strong> n = 2, presses = 1 |
| 31 | +<strong>Output:</strong> 3 |
| 32 | +<strong>Explanation:</strong> Status can be: |
| 33 | +- [off, off] by pressing button 1 |
| 34 | +- [on, off] by pressing button 2 |
| 35 | +- [off, on] by pressing button 3 |
| 36 | +</pre> |
| 37 | + |
| 38 | +<p><strong class="example">Example 3:</strong></p> |
| 39 | + |
| 40 | +<pre> |
| 41 | +<strong>Input:</strong> n = 3, presses = 1 |
| 42 | +<strong>Output:</strong> 4 |
| 43 | +<strong>Explanation:</strong> Status can be: |
| 44 | +- [off, off, off] by pressing button 1 |
| 45 | +- [off, on, off] by pressing button 2 |
| 46 | +- [on, off, on] by pressing button 3 |
| 47 | +- [off, on, on] by pressing button 4 |
| 48 | +</pre> |
| 49 | + |
| 50 | +<p> </p> |
| 51 | +<p><strong>Constraints:</strong></p> |
| 52 | + |
| 53 | +<ul> |
| 54 | + <li><code>1 <= n <= 1000</code></li> |
| 55 | + <li><code>0 <= presses <= 1000</code></li> |
| 56 | +</ul> |
0 commit comments