Tap here to switch tabs
Problem
Submissions

Problem: Gray Code

Try to solve the Gray Code problem.

Statement

An nn bit Gray code sequence is a sequence of 2n2^n integers where:

  • The first integer is 00.

  • Every integer appears at most once in the sequence.

  • The binary representation of every pair of adjacent integers differs by exactly one bit.

  • The binary representation of the first and last integers differs by exactly one bit.

Given an integer n, return any valid nn bit Gray code sequence.

Constraints:

  • 1≤1 \leq n ≤16\leq 16

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Gray Code

Try to solve the Gray Code problem.

Statement

An nn bit Gray code sequence is a sequence of 2n2^n integers where:

  • The first integer is 00.

  • Every integer appears at most once in the sequence.

  • The binary representation of every pair of adjacent integers differs by exactly one bit.

  • The binary representation of the first and last integers differs by exactly one bit.

Given an integer n, return any valid nn bit Gray code sequence.

Constraints:

  • 1≤1 \leq n ≤16\leq 16