Think Inside the Box

Babu Bhai (:p) is a student of AUST. He has some favorite numbers. His favorite numbers are those number that has only one distinct digit. Example: 7, 88, 222, 9999, etc. 123, 122, 33344 are not his favorite numbers. Now, you are given an positive integer N. You have to find a positive favorite number for Babu Bhai not greater that N.

This is a companion discussion topic for the original entry at