leetcode每日一题-319:灯泡开关

leetcode每日一题-319:灯泡开关

链接

灯泡开关



题目

在这里插入图片描述



分析

这里官方分析的很好,就直接采用官方的分析

在这里插入图片描述



代码

C++

class Solution {
public:
    int bulbSwitch(int n) {
        return (int)sqrt(n);
    }
};

Java

class Solution {
    
    
    public int bulbSwitch(int n) {
    
    
        return (int) Math.sqrt(n + 0.5);
    }
}

作者:LeetCode-Solution

猜你喜欢

转载自blog.csdn.net/qq_45826803/article/details/121338145