Skip to content

Latest commit

 

History

History
58 lines (31 loc) · 874 Bytes

README_EN.md

File metadata and controls

58 lines (31 loc) · 874 Bytes

中文文档

Description

Given a positive integer, print the next smallest and the next largest number that have the same number of 1 bits in their binary representation.

Example1:

 Input: num = 2 (0b10)

 Output: [4, 1] ([0b100, 0b1])

Example2:

 Input: num = 1

 Output: [2, -1]

Note:

  1. 1 <= num <= 2147483647
  2. If there is no next smallest or next largest number, output -1.

Solutions

Python3

Java

...