Tricky Google interview question

前端 未结 21 1708
花落未央
花落未央 2020-12-22 15:39

A friend of mine is interviewing for a job. One of the interview questions got me thinking, just wanted some feedback.

There are 2 non-negative integers: i and j. Gi

21条回答
  •  无人及你
    2020-12-22 16:13

    You have to keep track of the individual exponents of them, and what their sums would be

    so you start with f(0,0) --> 1 now you have to increment one of them:

    f(1,0) = 2
    f(0,1) = 5
    

    so we know 2 is the next - we also know we can increment i's exponent up until the sum surpases 5.

    You keep going back and forth like this until you're at your deisred number of rounds.

提交回复
热议问题