| 123456789101112131415161718 | 
							- func bulbSwitchSlow(n int) (res int) { // Brute search, TLE
 
- 	bulbs := make([]bool, n)
 
- 	for i := 1; i <= n; i++ {
 
- 		for j := i-1; j < n; j += i {
 
- 			bulbs[j] = !bulbs[j]
 
- 		}
 
- 	}
 
- 	for i := 0; i < n; i++ {
 
- 		if bulbs[i] {
 
- 			res++
 
- 		}
 
- 	}
 
- 	return
 
- }
 
- func bulbSwitch(n int) int { // Math
 
- 	return int(math.Sqrt(float64(n)))
 
- }
 
 
  |