Skip to content

Commit 040a48f

Browse files
committed
Added the solution for gray code problem
Look into this pr, this is my first pr, please guide me accordingly.
1 parent c819c4d commit 040a48f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

LeetCode/0089_Gray_code.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def gray(a):
2+
return ((a)^(a>>1))
3+
4+
class Solution:
5+
def grayCode(self, n: int) -> List[int]:
6+
ans=[]
7+
for i in range(pow(2,n)):
8+
ans.append(gray(i))
9+
return ans
10+
11+

0 commit comments

Comments
 (0)