Skip to content

Commit 704d51d

Browse files
committed
Mar 04
1 parent d3ea859 commit 704d51d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution:
2+
def checkPowersOfThree(self, n: int) -> bool:
3+
while n > 0:
4+
if n % 3 == 2:
5+
return False
6+
n //= 3
7+
return True
8+
9+
10+
def main():
11+
n = 12
12+
assert Solution().checkPowersOfThree(n) is True
13+
14+
n = 91
15+
assert Solution().checkPowersOfThree(n) is True
16+
17+
n = 21
18+
assert Solution().checkPowersOfThree(n) is False
19+
20+
21+
if __name__ == '__main__':
22+
main()

2025-03-March-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| March 01 | [2460. Apply Operations to an Array](https://leetcode.com/problems/apply-operations-to-an-array/) | Easy | Solved |
88
| March 02 | [2570. Merge Two 2D Arrays by Summing Values](https://leetcode.com/problems/merge-two-2d-arrays-by-summing-values/) | Easy | Solved |
99
| March 03 | [2161. Partition Array According to Given Pivot](https://leetcode.com/problems/partition-array-according-to-given-pivot/) | Medium | Solved |
10-
| March 04 | []() | | |
10+
| March 04 | [1780. Check if Number is a Sum of Powers of Three](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/) | Medium | Solved |
1111
| March 05 | []() | | |
1212
| March 06 | []() | | |
1313
| March 07 | []() | | |
@@ -41,5 +41,5 @@
4141
| Level | Problems | Solved | Unsolved |
4242
| --- | --- | --- | --- |
4343
| Easy | 2 | 2 | 0 |
44-
| Medium | 1 | 1 | 0 |
44+
| Medium | 2 | 1 | 1 |
4545
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)