Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Nov 27, 2023
1 parent 1b4004f commit 4988e11
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions leetcode/89.GrayCode/grayCode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
)

func grayCode(n int) []int {
ans := []int{}
for i := 0; i < 1<<n; i++ {
ans = append(ans, i^(i>>1))
}
return ans
}

func main() {
n := 2
fmt.Println(grayCode(n))
}

0 comments on commit 4988e11

Please sign in to comment.