File tree Expand file tree Collapse file tree 1 file changed +0
-20
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +0
-20
lines changed Original file line number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
2
3
- /**
4
- * 319. Bulb Switcher
5
- *
6
- * There are n bulbs that are initially off. You first turn on all the bulbs.
7
- * Then, you turn off every second bulb. On the third round,
8
- * you toggle every third bulb (turning on if it's off or turning off if it's on).
9
- * For the ith round, you toggle every i bulb. For the nth round, you only
10
- * toggle the last bulb. Find how many bulbs are on after n rounds.
11
-
12
- Example:
13
-
14
- Given n = 3.
15
-
16
- At first, the three bulbs are [off, off, off].
17
- After first round, the three bulbs are [on, on, on].
18
- After second round, the three bulbs are [on, off, on].
19
- After third round, the three bulbs are [on, off, off].
20
-
21
- So you should return 1, because there is only one bulb is on.
22
- */
23
3
public class _319 {
24
4
25
5
public static class Solution1 {
You can’t perform that action at this time.
0 commit comments