800. Similar RGB Color

Description

Here

Intuition

这题暴力一点,直接上个static array

  private static final int[] HEX = {
      0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
      0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd,
      0xee, 0xff
  };

然后用binary search找到最接近的value

Pitfall

如果找到index0,在转化为Hex String的时候别忘记补上 leading 0

Solution

Solution

results matching ""

    No results matching ""