class Solution { public: vector<int> grayCode(int n) { vector<int> result; int total = pow(2,n); for(int i = 0; i < total; ++i) { int code = (i >> 1) ^ i; result.emplace_back(code); } return result; } };
Post a Comment
No comments:
Post a Comment