forked from 7oSkaaa/LeetCode_DailyChallenge_2023
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 7oSkaaa#1008 from NouraAlgohary/main
add day 27 challenge
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Author: Noura Algohary | ||
|
||
class Solution { | ||
public: | ||
int bulbSwitch(int n) { | ||
// bulbs are counted (turned on) when it have odd number of divisors | ||
// only numbers with perfect square roots have odd divisors | ||
// to count the number of perfect square roots in n, | ||
// it must be equal to sqrt(n) | ||
return sqrt(n); | ||
} | ||
}; |
11 changes: 11 additions & 0 deletions
11
04- April/27- Bulb Switcher/27- Bulb Switcher (Noura Algohary).py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Author: Noura Algohary | ||
|
||
class Solution: | ||
def bulbSwitch(self, n: int) -> int: | ||
# bulbs are counted (turned on) when it have odd number of divisors | ||
# only numbers with perfect square roots have odd divisors | ||
# to count the number of perfect square roots in n, | ||
# it must be equal to sqrt(n) | ||
|
||
return int(n ** 0.5) | ||
|