Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bc2ab03

Browse files
zhangzz2015gitbook-bot
authored andcommitted
GitBook: [greyireland#93] No subject
1 parent df0c7e3 commit bc2ab03

File tree

3 files changed

+34
-60
lines changed

3 files changed

+34
-60
lines changed

‎SUMMARY.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* [二分搜索](basic\_algorithm/binary\_search.md)
2121
* [排序算法](basic\_algorithm/sort.md)
2222
* [动态规划](basic\_algorithm/dp.md)
23-
* [位运算](ji-chu-suan-fa-pian/wei-yun-suan.md)
2423

2524
## 算法思维
2625

‎data_structure/binary_op.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,40 @@ func rangeBitwiseAnd(m int, n int) int {
296296
}
297297
```
298298

299+
#### [Gray Code](https://leetcode.com/problems/gray-code/)
300+
301+
```cpp
302+
// Some code
303+
class Solution {
304+
public:
305+
vector<int> grayCode(int n) {
306+
307+
vector<int> ret;
308+
for(int i=0; i<n; i++)
309+
{
310+
if(i==0)
311+
{
312+
ret.push_back(0);
313+
ret.push_back(1);
314+
}
315+
else
316+
{
317+
int sum = 1<<i;
318+
int isize = ret.size();
319+
for(int j=isize-1; j>=0; j--)
320+
{
321+
ret.push_back(ret[j]+sum);
322+
}
323+
}
324+
}
325+
326+
return ret;
327+
328+
}
329+
};
330+
331+
```
332+
299333
## 练习
300334
301335
* [ ] [single-number](https://leetcode-cn.com/problems/single-number/)

‎ji-chu-suan-fa-pian/wei-yun-suan.md‎

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /