0 ms no additional library functions

  • 0

    There are a ton of sqrt functions. I just wanted to post bottom up C solution.

    Considering its a 32bit integer input, maximum run time would be a 65,535 iteration.

    int bulbSwitch(int n) {
        int i =1, res=0;
        if(!n) return 0;
        while((i*i) <= n) {
        return res;

  • 1

    int bulbSwitch(int n)
    return sqrt(n);

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.