https://www.codechef.com/ROCS2021/problems/ROCPERM

https://www.codechef.com/ROCS2021/problems/ROCPERM

mostly people using simple sort() they don’t check the sub array is divisible by 3 or not and all the test case pass why???

Every 3 consecutive numbers are divisible by 3.

Every three consecutive number will be of the forms:
3n,3n+1,3n+2
or 3n+1,3n+2,3n
or 3n+2,3n,3n+1
and sum will be = 9n+3 = 3(3n+1), so every 3 consecutive number will be divisible by 3.
In general every consecutive sum of n numbers is divisible by n, when n is odd.