Блог пользователя alibaba

Автор alibaba, 10 лет назад, По-английски

I am trying to solve 1000 pt problem and I have doubt about the sample case:

{2, 7, 3, 0, 6, 4, 5, 1} Returns: {1, 7, 3, 0, 6, 2, 5, 4 }

But when I manually solved it, I found a better permutation {1,7,3,0,2,4,5,6}. So is the problem correct? Any one can help?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

"If there are several such permutations Q, return the one among them that has the lexicographically smallest child array."

If I don't miss something, your answer's child array is {0, 1, 7, 6, 5, 4, 2, 3} and their answer's child array is {0, 1, 7, 4, 6, 5, 2, 3}, which is lexicographically smaller than yours.