89.Gray Code

class Solution {
public:
     vector<int> grayCode(int n) {
         vector<int> result;
         for(int i=0;i<1<<n;i++)
         {
             result.push_back(i^i>>1);
         }
         return result;
     }

};
posted @ 2019-04-09 12:07  JohnRed  阅读(88)  评论(0)    收藏  举报