Official

B - Permutation Check Editorial by en_translator


One can check if each of 1,2,3,,N1, 2, 3, \dots, N as an element of AA to solve in a total of O(N)O(N) time time.

Sample code (C++)

Otherwise, one can sort the elements of AA in the increasing order and check if 1,2,,N1, 2, \dots, N are in this order to solve in a total of O(NlogN)O (N \log N) time.

Sample code (C++)

Sample code (Python)

posted:
last update:



2025-04-03 (Thu)
18:21:01 +00:00