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, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2 , 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4 , 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6 , 5, 4, 3, 2, 1, 0]]
[0.2초 만에 완료]
왜 결과가 똑같아지나요?
滿天的星座2017-05-18 11:02:11
문제는 generate_next_permutation_in_lexicographic_order 함수에 있습니다.
Python의 List는 변수 유형이므로 실제로 전역적으로 하나의 List만 작동한 다음 동일한 List에 대한 참조를 결과에 계속해서 입력하면 물론 다음과 같습니다.
간단한 수정: