Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 427 Bytes

File metadata and controls

22 lines (19 loc) · 427 Bytes

LeetCode Records - Question 319 Bulb Switcher

Attempt 1: Find the pattern first

class Solution {
    public int bulbSwitch(int n) {
        int count = 0;
        int factor = 3;
        while (n > 0) {
            n -= factor;
            factor += 2;
            count++;
        }

        return count;
    }
}
  • Runtime: 0 ms (Beats: 100.00%)
  • Memory: 40.10 MB (Beats: 71.92%)