How to tell if an array is a permutation in O(n)?

后端 未结 16 1642
粉色の甜心
粉色の甜心 2020-12-07 10:17

Input: A read-only array of N elements containing integer values from 1 to N (some integer values can appear more than once!). And a memory zone of a fixed<

16条回答
  •  [愿得一人]
    2020-12-07 10:40

    it's a permutation if and only if there are no duplicate values in the array, should be easy to check that in O(N)

提交回复
热议问题