Skip to content

Commit 3be84ec

Browse files
authored
feat: add typescript solution to lc problem: No.0231.Power of Two (doocs#427)
1 parent c2456e3 commit 3be84ec

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

solution/0200-0299/0231.Power of Two/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ func isPowerOfTwo(n int) bool {
8484
}
8585
```
8686

87+
### **TypeScript**
88+
89+
```ts
90+
function isPowerOfTwo(n: number): boolean {
91+
return n > 0 && (n & (n - 1)) == 0;
92+
};
93+
```
94+
8795
### **...**
8896

8997
```

solution/0200-0299/0231.Power of Two/README_EN.md

+8
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ func isPowerOfTwo(n int) bool {
109109
}
110110
```
111111

112+
### **TypeScript**
113+
114+
```ts
115+
function isPowerOfTwo(n: number): boolean {
116+
return n > 0 && (n & (n - 1)) == 0;
117+
};
118+
```
119+
112120
### **...**
113121

114122
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function isPowerOfTwo(n: number): boolean {
2+
return n > 0 && (n & (n - 1)) == 0;
3+
};

0 commit comments

Comments
 (0)