Last updated 5 years ago
Was this helpful?
这道题就是脑筋急转弯。
简单讲,就是找小于 n 的完全平方数的个数(因为他们的 factor 的个数是奇数)
而这样又直接等于 n 开方
public class Solution { public int bulbSwitch(int n) { return (int) Math.sqrt(n); } }