Skip to content

Commit

Permalink
Add new daily problem to README
Browse files Browse the repository at this point in the history
  • Loading branch information
7oSkaaa committed Apr 27, 2023
1 parent 201ed0b commit 8b713a2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 04- April/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
1. **[Last Stone Weight](#24--last-stone-weight)**
1. **[Smallest Number in Infinite Set](#25--smallest-number-in-infinite-set)**
1. **[Add Digits](#26--add-digits)**
1. **[Bulb Switcher](#27--bulb-switcher)**

<hr>
<br><br>
Expand Down Expand Up @@ -1499,4 +1500,36 @@ public:
}
};
```
<hr>
<br><br>
## 27) [Bulb Switcher](https://leetcode.com/problems/bulb-switcher/)
### Difficulty
![](https://img.shields.io/badge/Medium-orange?style=for-the-badge)
### Related Topic
`Math` `Brainteaser`
### Code
```cpp
class Solution {
public:
int bulbSwitch(int n) {
// for this problem we need to know how many light bulbs are on after n rounds
// to know that you need to know for each light bulb to stay on at the end it needs to have odd number of divisors
// the only numbers that have odd number of divisors are perfect squares
// so the answer is the number of perfect squares less than or equal to n
// which is sqrt(n)
return sqrt(n);
}
};
```

0 comments on commit 8b713a2

Please sign in to comment.