【LeetCode】 319. Bulb Switcher
来源:互联网 发布:监控电脑屏幕的软件 编辑:程序博客网 时间:2024/05/18 01:54
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the ith round, you toggle every i bulb. For the nth round, you only toggle the last bulb. Find how many bulbs are on after n rounds.
Example:
Given n = 3.
At first, the three bulbs are [off, off, off].After first round, the three bulbs are [on, on, on].After second round, the three bulbs are [on, off, on].After third round, the three bulbs are [on, off, off].
So you should return 1, because there is only one bulb is on.
public class Solution { public int bulbSwitch(int n) { return (int) Math.sqrt(n); }}
0 0
- [leetcode] 319. Bulb Switcher
- leetcode 319. Bulb Switcher
- 319. Bulb Switcher LeetCode
- LeetCode 319. Bulb Switcher
- LeetCode *** 319. Bulb Switcher
- [leetcode]319. Bulb Switcher
- leetcode-319. Bulb Switcher
- leetcode 319. Bulb Switcher
- leetcode 319. Bulb Switcher
- 【leetcode】319. Bulb Switcher
- [Leetcode] 319. Bulb Switcher
- LeetCode-319.Bulb Switcher
- Leetcode 319. Bulb Switcher
- 【LeetCode】319. Bulb Switcher
- [leetcode] 319.Bulb Switcher
- 【leetcode】319. Bulb Switcher
- [leetcode] 319. Bulb Switcher
- [LeetCode]319. Bulb Switcher
- windows mysql 自动备份的几种方法
- LeetCode 370. Range Addition
- Java之Redis队列+Websocket+定时器实现跑马灯实时刷新
- T-SQL概述(常量变量运算符)
- Palindrome Linked List
- 【LeetCode】 319. Bulb Switcher
- 在行为树(Behavior Tree)中使用黑板(BlackBoard)
- 【LeetCode】 328. Odd Even Linked List
- VS_Enterprise2017RC初体验-安装篇
- 237. Delete Node in a Linked List
- 80老翁谈人生(334):网络空间主权是什么?
- Leetcode 359 Logger Rate Limiter
- spring基础:快速入门spring cloud(6):统一配置管理之spring cloud config
- Leetcode Insert Interval