Find the kth eleven-non-free number

前端 未结 8 2122
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 10:10

Let\'s define eleven-non-free numbers:

If we consider a number as a string, then if any substring inside is a (non-zero) power of 11, then this

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 10:42

    given a k, find the kth eleven-non-free number.... is a big question.

    Since this is time taking question, I am writing pseudo code.

    1. First step Keep the powers of eleven handy

    var eleven_powers = []; for (var i=0; i<1000; i++) eleven_powers.push(Math.pow(11,i));

    1. Second Step Keep all possible non-eleven-free numbers to an extent you can. This will have to deal with big integers.

    for (var i=11; i

    1. Third Step Take k, return results_array[k]

提交回复
热议问题