codes of bits-bit binary codes: every number is between 0 and 2^bits - 1. The distance between two codes is the number of bit positions where they differ (numbers are padded with leading zeros to bits positions).
For each code codes[i], find the largest distance between it and any other element codes[j] of the array (j ≠ i; the values themselves may be equal).
Return an array of answers with the same length as codes.codes=[5, 2, 7], bits=3 → [3, 3, 2]
In binary these are 101, 010 and 111. Codes 101 and 010 differ in all three positions. For 111 the farthest code is 010, which differs in 2 positions.
codes=[0, 0], bits=2 → [0, 0]
Both codes are equal, so the distance between them is 0.
codes=[5, 2, 7], bits=3
[3, 3, 2]
Run checks the first 3 tests in your browser. Submit checks all 70 tests on the server, hidden ones included.