672. Bulb Switcher II Medium

@problem@discussion
#Math#Bit Manipulation#Depth-First Search#Breadth-First Search



1/**
2 * [672] Bulb Switcher II
3 *
4 * There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall. Each of the four buttons has a different functionality where:
5 * 
6 * 	Button 1: Flips the status of all the bulbs.
7 * 	Button 2: Flips the status of all the bulbs with even labels (i.e., 2, 4, ...).
8 * 	Button 3: Flips the status of all the bulbs with odd labels (i.e., 1, 3, ...).
9 * 	Button 4: Flips the status of all the bulbs with a label j = 3k + 1 where k = 0, 1, 2, ... (i.e., 1, 4, 7, 10, ...).
10 * 
11 * You must make exactly presses button presses in total. For each press, you may pick any of the four buttons to press.
12 * Given the two integers n and presses, return the number of different possible statuses after performing all presses button presses.
13 *  
14 * Example 1:
15 * 
16 * Input: n = 1, presses = 1
17 * Output: 2
18 * Explanation: Status can be:
19 * - [off] by pressing button 1
20 * - [on] by pressing button 2
21 * 
22 * Example 2:
23 * 
24 * Input: n = 2, presses = 1
25 * Output: 3
26 * Explanation: Status can be:
27 * - [off, off] by pressing button 1
28 * - [on, off] by pressing button 2
29 * - [off, on] by pressing button 3
30 * 
31 * Example 3:
32 * 
33 * Input: n = 3, presses = 1
34 * Output: 4
35 * Explanation: Status can be:
36 * - [off, off, off] by pressing button 1
37 * - [off, on, off] by pressing button 2
38 * - [on, off, on] by pressing button 3
39 * - [off, on, on] by pressing button 4
40 * 
41 *  
42 * Constraints:
43 * 
44 * 	1 <= n <= 1000
45 * 	0 <= presses <= 1000
46 * 
47 */
48pub struct Solution {}
49
50// problem: https://leetcode.com/problems/bulb-switcher-ii/
51// discuss: https://leetcode.com/problems/bulb-switcher-ii/discuss/?currentPage=1&orderBy=most_votes&query=
52
53// submission codes start here
54
55impl Solution {
56    pub fn flip_lights(n: i32, presses: i32) -> i32 {
57        0
58    }
59}
60
61// submission codes end
62
63#[cfg(test)]
64mod tests {
65    use super::*;
66
67    #[test]
68    fn test_672() {
69    }
70}
71


Back
© 2025 bowen.ge All Rights Reserved.